Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for Drupal 10 github action #855

Closed
wants to merge 9 commits into from
11 changes: 6 additions & 5 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
drupal-core:
# Should update the following as the minimum supported version from Drupal.org
- "10.0.x"
- "10.1.x"

steps:

Expand Down Expand Up @@ -95,7 +96,7 @@ jobs:
composer update --with-all-dependencies
composer require --dev phpspec/prophecy-phpunit:^2
composer config --no-plugins allow-plugins.drupal/console-extend-plugin true
composer require --dev drupal/console --with-dependencies
# composer require --dev drupal/console --with-dependencies


# Install drupal using minimal installation profile and enable the module.
Expand All @@ -112,10 +113,10 @@ jobs:
cp modules/contrib/apigee_edge/phpcs.xml.dist .
vendor/bin/phpcs --standard=./phpcs.xml.dist modules/contrib/apigee_edge -p -s -n --colors

- name: "Drupal check"
run: |
cd drupal
vendor/bin/drupal-check modules/contrib/apigee_edge
# - name: "Drupal check"
# run: |
# cd drupal
# vendor/bin/drupal-check modules/contrib/apigee_edge

- uses: nanasess/setup-chromedriver@v1

Expand Down
2 changes: 1 addition & 1 deletion apigee_edge.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ dependencies:

configure: apigee_edge.settings

php: "8.1"
php: 8.1
2 changes: 1 addition & 1 deletion apigee_edge.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ apigee_edge.components:
css/apigee_edge.components.css: {}

apigee_edge.app_listing:
version: 1.0
version: 1.1
css:
theme:
css/apigee_edge.app_listing.css: {}
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
"drupal/drupal-extension": "^4.2.1 || ~5",
"cweagans/composer-patches": "^1.6",
"drupal/core-dev": "^10.0",
"drush/drush": "^11.5",
"drush/drush": "^12.0",
"mglaman/drupal-check": "1.3",
"phpmd/phpmd": "^2.8.2",
"phpmetrics/phpmetrics": "^2.5",
"phpstan/phpstan": "^1.5"
"phpstan/phpstan": "^1.5",
"drupal/classy": "^1.0"
},
"suggest": {
"drupal/console": "Needed only to run tests in Drupal 8."
Expand Down
6 changes: 3 additions & 3 deletions js/apigee_edge.app_listing.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @file
* Javascript functions related to the app listing.
*/
(function ($, Drupal) {
(function ($, Drupal, once) {

'use strict';

Expand All @@ -31,7 +31,7 @@

Drupal.apigeeEdgeAppListing = {
tableToggle: function (context, settings) {
$('.toggle--warning').once('tableToggle').on('click', function (event) {
$(once('tableToggle', '.toggle--warning')).on('click', function (event) {
event.preventDefault();
var targetURL = $(this).attr('href');
var targetID = '#' + targetURL.substr(targetURL.indexOf('#') + 1);
Expand All @@ -50,4 +50,4 @@

}
};
})(jQuery, Drupal);
})(jQuery, Drupal, once);
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@

namespace Drupal\apigee_edge_actions\EventSubscriber;

use Drupal\apigee_edge_actions\Event\EdgeEntityEventEdge;
use Drupal\apigee_edge\Entity\AppInterface;
use Drupal\apigee_edge\Event\AppCredentialAddApiProductEvent;
use Drupal\apigee_edge\Event\AppCredentialDeleteApiProductEvent;
use Drupal\apigee_edge_actions\Event\EdgeEntityEventEdge;
use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Logger\LoggerChannelInterface;
use Drupal\Core\Session\AccountInterface;
use Symfony\Contracts\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Contracts\EventDispatcher\Event;

/**
* Events for an API Product being added to an app already exist.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

namespace Drupal\apigee_edge_actions\Plugin\RulesEvent;

use Drupal\apigee_edge_actions\ApigeeActionsEntityTypeHelperInterface;
use Drupal\apigee_edge\Entity\AppInterface;
use Drupal\apigee_edge\Entity\EdgeEntityTypeInterface;
use Drupal\apigee_edge_actions\ApigeeActionsEntityTypeHelperInterface;
use Drupal\apigee_edge_teams\Entity\TeamAppInterface;
use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\Core\StringTranslation\StringTranslationTrait;
Expand Down
2 changes: 1 addition & 1 deletion modules/apigee_edge_actions/src/TeamMembershipManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

namespace Drupal\apigee_edge_actions;

use Drupal\apigee_edge_actions\Event\EdgeEntityEventEdge;
use Drupal\apigee_edge\Entity\Controller\DeveloperControllerInterface;
use Drupal\apigee_edge\Entity\DeveloperCompaniesCacheInterface;
use Drupal\apigee_edge_actions\Event\EdgeEntityEventEdge;
use Drupal\apigee_edge_teams\CompanyMembersControllerFactoryInterface;
use Drupal\apigee_edge_teams\TeamMembershipManagerInterface;
use Drupal\Core\Cache\CacheTagsInvalidatorInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: "Support module for the Apigee Edge API Product RBAC tests."
package: Testing

type: module
core_version_requirement: ^8 || ^9
core_version_requirement: ^10

dependencies:
- apigee_edge:apigee_edge_apiproduct_rbac
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
use Drupal\apigee_edge_debug\DebugMessageFormatterPluginManager;
use Drupal\apigee_edge_debug\SDKConnector;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Session\AccountInterface;
use GuzzleHttp\RequestOptions;
use GuzzleHttp\TransferStats;
use Psr\Http\Message\RequestInterface;
Expand Down
2 changes: 1 addition & 1 deletion modules/apigee_edge_teams/src/CliService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

namespace Drupal\apigee_edge_teams;

use Drupal\apigee_edge_teams\Controller\TeamMemberSyncController;
use Drupal\apigee_edge\Command\Util\ApigeeEdgeManagementCliServiceInterface;
use Drupal\apigee_edge_teams\Controller\TeamMemberSyncController;
use Symfony\Component\Console\Style\StyleInterface;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

namespace Drupal\apigee_edge_teams\Controller;

use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\apigee_edge\Controller\DeveloperAppKeysController;
use Symfony\Component\HttpFoundation\JsonResponse;

/**
* Controller for the team app credentials.
Expand All @@ -37,7 +37,10 @@ public function teamAppKeys($team, $app): JsonResponse {
$payload = [];
if ($team) {
$app_storage = $this->entityTypeManager->getStorage('team_app');
// Lists all the team apps ids.
// Team app is accessible to all the team members.
$app_ids = $app_storage->getQuery()
->accessCheck(FALSE)
->condition('companyName', $team->id())
->condition('name', $app->getName())
->execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

namespace Drupal\apigee_edge_teams\Controller;

use Drupal\apigee_edge_teams\Job\TeamMemberSync;
use Drupal\apigee_edge\Job\Job;
use Drupal\apigee_edge\JobExecutorInterface;
use Drupal\apigee_edge_teams\Job\TeamMemberSync;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Messenger\MessengerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
Expand Down
4 changes: 3 additions & 1 deletion modules/apigee_edge_teams/src/Controller/TeamMembersList.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

namespace Drupal\apigee_edge_teams\Controller;

use Drupal\apigee_edge_teams\Entity\TeamMemberRoleInterface;
use Drupal\apigee_edge_teams\Entity\TeamInterface;
use Drupal\apigee_edge_teams\Entity\TeamMemberRoleInterface;
use Drupal\apigee_edge_teams\Entity\TeamRoleInterface;
use Drupal\apigee_edge_teams\TeamMembershipManagerInterface;
use Drupal\Component\Utility\Html;
Expand Down Expand Up @@ -115,7 +115,9 @@ public function overview(TeamInterface $team) {

if (!empty($members)) {
$user_storage = $this->entityTypeManager()->getStorage('user');
// Only members with access can view the member list.
$uids = $user_storage->getQuery()
->accessCheck(TRUE)
->condition('mail', $members, 'IN')
->execute();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

namespace Drupal\apigee_edge_teams\Entity\Controller;

use Drupal\apigee_edge\Entity\Controller\Cache\AppCacheByOwnerFactoryInterface;
use Drupal\apigee_edge\Entity\Controller\Cache\AppCacheInterface;
use Drupal\apigee_edge\Entity\Controller\Cache\AppNameCacheByOwnerFactoryInterface;
use Drupal\apigee_edge\Entity\Controller\Cache\AppCacheByOwnerFactoryInterface;
use Drupal\apigee_edge\Entity\Controller\OrganizationControllerInterface;
use Drupal\apigee_edge\SDKConnectorInterface;

Expand Down
7 changes: 5 additions & 2 deletions modules/apigee_edge_teams/src/Entity/Form/TeamForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,11 @@ public function exists(string $name, array $element, FormStateInterface $form_st
if ($name === '') {
return FALSE;
}

$query = $this->entityTypeManager->getStorage('team')->getQuery()->condition('name', $name);
// Only member with access can check if team exists.
$query = $this->entityTypeManager->getStorage('team')
->getQuery()
->accessCheck(TRUE)
->condition('name', $name);

return (bool) $query->count()->execute();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected function invokeHook($hook, EntityInterface $entity) {
* {@inheritdoc}
*/
public function loadByRecipient(string $email, ?string $team_id = NULL): array {
$query = $this->getQuery()->condition('recipient', $email);
$query = $this->getQuery()->accessCheck(TRUE)->condition('recipient', $email);

if ($team_id) {
$query->condition('team', $team_id);
Expand All @@ -161,7 +161,8 @@ public function loadByRecipient(string $email, ?string $team_id = NULL): array {
* {@inheritdoc}
*/
public function getInvitationsToExpire(): array {
$query = $this->getQuery()->condition('expiry', $this->time->getCurrentTime(), '<')
// Team invitation is accessable as we need to update status in cron run.
$query = $this->getQuery()->accessCheck(FALSE)->condition('expiry', $this->time->getCurrentTime(), '<')
->condition('status', TeamInvitationInterface::STATUS_PENDING);

$ids = $query->execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

namespace Drupal\apigee_edge_teams\Entity\Storage;

use Drupal\apigee_edge_teams\Entity\TeamMemberRoleInterface;
use Drupal\apigee_edge_teams\Entity\TeamInterface;
use Drupal\apigee_edge_teams\Entity\TeamMemberRoleInterface;
use Drupal\apigee_edge_teams\Exception\InvalidArgumentException;
use Drupal\apigee_edge_teams\TeamMembershipManagerInterface;
use Drupal\Core\Cache\Cache;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

namespace Drupal\apigee_edge_teams\Entity\Storage;

use Drupal\apigee_edge_teams\Entity\TeamMemberRoleInterface;
use Drupal\apigee_edge_teams\Entity\TeamInterface;
use Drupal\apigee_edge_teams\Entity\TeamMemberRoleInterface;
use Drupal\Core\Entity\ContentEntityStorageInterface;
use Drupal\Core\Session\AccountInterface;

Expand Down
4 changes: 2 additions & 2 deletions modules/apigee_edge_teams/src/Entity/TeamAppRouteProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

use Drupal\apigee_edge\Entity\AppRouteProvider;
use Drupal\apigee_edge\Entity\AppTitleProvider;
use Drupal\apigee_edge_teams\Entity\ListBuilder\TeamAppListByTeam;
use Drupal\apigee_edge_teams\Controller\TeamAppKeysController;
use Drupal\apigee_edge_teams\Form\TeamAppApiKeyDeleteForm;
use Drupal\apigee_edge_teams\Entity\ListBuilder\TeamAppListByTeam;
use Drupal\apigee_edge_teams\Form\TeamAppApiKeyAddForm;
use Drupal\apigee_edge_teams\Form\TeamAppApiKeyDeleteForm;
use Drupal\apigee_edge_teams\Form\TeamAppApiKeyRevokeForm;
use Drupal\Core\Entity\EntityTypeInterface;
use Symfony\Component\Routing\Route;
Expand Down
2 changes: 1 addition & 1 deletion modules/apigee_edge_teams/src/Entity/TeamInvitation.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\user\EntityOwnerTrait;
use Drupal\user\UserInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
use Drupal\apigee_edge\Event\AppCredentialDeleteEvent;
use Drupal\apigee_edge\Event\AppCredentialGenerateEvent;
use Drupal\apigee_edge_teams\TeamMemberApiProductAccessHandlerInterface;
use Symfony\Contracts\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Contracts\EventDispatcher\Event;

/**
* Ensures team member API product access handler's cache gets cleared.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

use Drupal\apigee_edge_teams\Entity\TeamInterface;
use Drupal\apigee_edge_teams\TeamMembershipManagerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ public function convert($value, $definition, $name, array $defaults) {
$team = is_object($defaults['team']) ? $defaults['team'] : $this->entityTypeManager->getStorage('team')->load($defaults['team']);
if ($team) {
$app_storage = $this->entityTypeManager->getStorage('team_app');
// Lists all the team apps ids.
// Team app is accessible to all the team members.
$app_ids = $app_storage->getQuery()
->accessCheck(FALSE)
->condition('companyName', $team->id())
->condition('name', $value)
->execute();
Expand Down
24 changes: 14 additions & 10 deletions modules/apigee_edge_teams/src/TeamMembershipManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,22 @@ public function removeMembers(string $team, array $developers): void {
$controller->removeMember($developer);
// Remove team member's roles from Drupal.
if (array_key_exists($developer, $users_by_mail)) {
/** @var \Drupal\apigee_edge_teams\Entity\TeamMemberRoleInterface[] $team_member_roles_in_teams */
$team_member_roles_in_teams = $team_member_role_storage->loadByDeveloper($users_by_mail[$developer]);
foreach ($team_member_roles_in_teams as $team_member_roles_in_team) {
try {
/** @var \Drupal\user\Entity\User $account */
$account = user_load_by_mail($users_by_mail[$developer]->getEmail());
$team_entity = $this->entityTypeManager->getStorage('team')->load($team);

/** @var \Drupal\apigee_edge_teams\Entity\TeamMemberRoleInterface[] $team_member_roles_in_team */
$team_member_roles_in_team = $team_member_role_storage->loadByDeveloperAndTeam($account, $team_entity);
try {
if (!empty($team_member_roles_in_team)) {
$team_member_roles_in_team->delete();
}
catch (EntityStorageException $e) {
$this->logger->critical("Failed to remove %developer team member's roles in %team team with its membership.", [
'%developer' => $developer,
'%team' => $team_member_roles_in_team->getTeam()->id(),
]);
}
}
catch (EntityStorageException $e) {
$this->logger->critical("Failed to remove %developer team member's roles in %team team with its membership.", [
'%developer' => $developer,
'%team' => $team_member_roles_in_team->getTeam()->id(),
]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/CliService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

namespace Drupal\apigee_edge;

use Drupal\apigee_edge\Controller\DeveloperSyncController;
use Drupal\apigee_edge\Command\Util\ApigeeEdgeManagementCliServiceInterface;
use Drupal\apigee_edge\Controller\DeveloperSyncController;
use Symfony\Component\Console\Style\StyleInterface;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Command/CommandBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
namespace Drupal\apigee_edge\Command;

use Drupal\apigee_edge\CliServiceInterface;
use Drupal\Console\Core\Command\Command;
use Drupal\Console\Core\Command\Shared\CommandTrait;
use Drupal\Console\Core\Style\DrupalStyle;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\Logger\LogMessageParserInterface;
use Drupal\Console\Core\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Logger\ConsoleLogger;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Util/ApigeeEdgeManagementCliService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

namespace Drupal\apigee_edge\Command\Util;

use Apigee\Edge\ClientInterface as ApigeeClientInterface;
use Drupal\Component\Utility\UrlHelper;
use GuzzleHttp\ClientInterface;
use Apigee\Edge\ClientInterface as ApigeeClientInterface;
use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Exception\TransferException;
use Symfony\Component\Console\Style\StyleInterface;
Expand Down
Loading
Loading