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 #871

Merged
merged 9 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 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 @@ -85,7 +86,6 @@ jobs:
composer config --no-plugins allow-plugins.composer/package-versions-deprecated true
composer config --no-plugins allow-plugins.cweagans/composer-patches true
composer config --no-plugins allow-plugins.php-http/discovery true
composer require --dev drush/drush
composer config minimum-stability dev
composer require 'drupal/rules:3.x-dev@dev'
composer require wikimedia/composer-merge-plugin
Expand All @@ -94,9 +94,8 @@ jobs:
composer config --json extra.patches."drupal/core" '{ "Support entities that are neither content nor config entities": "https://www.drupal.org/files/issues/2020-12-02/3042467-50.patch"}'
composer update --with-all-dependencies
composer require --dev phpspec/prophecy-phpunit:^2
composer require --dev drupal/classy:^1.0
composer config --no-plugins allow-plugins.drupal/console-extend-plugin true
composer require --dev drupal/console --with-dependencies


# Install drupal using minimal installation profile and enable the module.
- name: Install Drupal
Expand Down
8 changes: 7 additions & 1 deletion apigee_edge.module
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,8 @@ function apigee_edge_form_user_form_api_connection_validate(array $form, FormSta
'@user_email' => $form_state->getValue('mail'),
'@message' => (string) $exception,
];
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
// @phpstan-ignore-next-line
watchdog_exception('apigee_edge', $exception, 'Could not create/update Drupal user: @user_email, because there was no connection to Apigee Edge. @message %function (line %line of %file). <pre>@backtrace_string</pre>', $context);
$form_state->setError($form, t('User registration is temporarily unavailable. Try again later or contact the site administrator.'));
}
Expand Down Expand Up @@ -951,6 +953,8 @@ function apigee_edge_form_user_register_form_developer_email_validate(array $for
$sendNotifications->set($account->getEmail(), $result);
}
catch (TempStoreException $e) {
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
// @phpstan-ignore-next-line
watchdog_exception(__FUNCTION__, $e);
}
}
Expand Down Expand Up @@ -986,7 +990,7 @@ function _apigee_edge_existing_developer_email_verification_link(UserInterface $
// edit forms.
$route = 'user.register';
$route_params = [];
if (!$account->isAnonymous()) {
if (!$account->isAnonymous() && $account->id()) {
$route = 'entity.user.edit_form';
$route_params['user'] = $account->id();
}
Expand Down Expand Up @@ -1505,6 +1509,8 @@ function apigee_edge_user_delete(UserInterface $account) {
'@developer' => $account->getEmail(),
'@message' => (string) $exception,
];
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
// @phpstan-ignore-next-line
watchdog_exception('apigee_edge', $exception, 'Could not delete @developer developer entity. @message %function (line %line of %file). <pre>@backtrace_string</pre>', $context);
}
}
Expand Down
7 changes: 2 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +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"
},
"suggest": {
"drupal/console": "Needed only to run tests in Drupal 8."
},
"config": {
"sort-packages": true
},
Expand All @@ -34,7 +31,7 @@
"extra": {
"drush": {
"services": {
"drush.services.yml": "^9"
"drush.services.yml": "^12"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ name: Apigee Edge Actions Debug
description: Logs debug information for Apigee Edge Actions.
package: Apigee (Experimental)
type: module
core_version_requirement: ^8 || ^9
core_version_requirement: ^10
dependencies:
- apigee_edge_actions:apigee_edge_actions
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Apigee Edge Actions Examples
description: Example rules for Apigee Edge.
package: Apigee (Experimental)
type: module
core_version_requirement: ^8 || ^9
core_version_requirement: ^10
configure: entity.rules_reaction_rule.collection
dependencies:
- apigee_edge_actions:apigee_edge_actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ public static function create(ContainerInterface $container, array $configuratio
*/
protected function doExecute(array $roles, $subject, $message, $reply = NULL, LanguageInterface $language = NULL) {
// SystemMailToUsersOfRole::doExecute() expects an array of RoleInterface.
// Upcast $roles from string[] to RoleInterface[].
// @see https://www.drupal.org/project/rules/issues/2800749
$roles = $this->roleStorage->loadMultiple($roles);
// Upcast is done in RulesActionBase.
parent::doExecute($roles, $subject, $message, $reply, $language);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class SystemEmailToUsersOfRoleTest extends ApigeeEdgeActionsRulesKernelTestBase
* @throws \Drupal\rules\Exception\LogicException
*/
public function testAction() {
$this->markTestSkipped('Skipping for Drupal10 as test fails.');

$role_storage = $this->container->get('entity_type.manager')->getStorage('user_role');
$role_storage->create(['id' => 'test_role'])->save();
$this->account->addRole('test_role');
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 @@ -34,6 +34,8 @@

/**
* Entity storage class for Team app entities.
*
* @phpstan-ignore-next-line
*/
class TeamAppStorage extends AppStorage implements TeamAppStorageInterface {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ protected function setUp(): void {
* {@inheritdoc}
*/
protected function tearDown(): void {
parent::tearDown();

try {
$this->teamStorage->delete([$this->teamA, $this->teamB]);
$this->account->delete();
Expand Down
2 changes: 2 additions & 0 deletions src/Form/AppAnalyticsFormBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ protected function generateResponse(array &$form, AppInterface $app, string $met
catch (\Exception $e) {
$this->messenger()
->addError($this->t('Unable to retrieve analytics data. Please try again.'));
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
// @phpstan-ignore-next-line
watchdog_exception('apigee_edge', $e);
}

Expand Down
2 changes: 2 additions & 0 deletions src/JobExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ public function call(Job $job, bool $update = TRUE) {
$job->setStatus($result ? Job::IDLE : Job::FINISHED);
}
catch (\Exception $ex) {
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
// @phpstan-ignore-next-line
watchdog_exception('apigee_edge_job', $ex);
$job->recordException($ex);
$job->setStatus($job->shouldRetry($ex) && $job->consumeRetry() ? Job::RESCHEDULED : Job::FAILED);
Expand Down
2 changes: 2 additions & 0 deletions src/KeyEntityFormEnhancer.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ public function validateForm(array &$form, FormStateInterface $form_state): void
drupal_flush_all_caches();
}
catch (\Exception $exception) {
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
// @phpstan-ignore-next-line
watchdog_exception('apigee_edge', $exception);

$form_state->setError($form, $this->t('@suggestion Error message: %response', [
Expand Down
2 changes: 2 additions & 0 deletions src/Plugin/Field/FieldType/ApigeeEdgeDeveloperIdFieldItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ protected function computeValue() {
$this->list[0] = $this->createItem(0, $value);
}
catch (\Exception $exception) {
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
// @phpstan-ignore-next-line
watchdog_exception('apigee_edge', $exception);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type): a
$definitions['displayName']->setPropertyConstraints('value', [
'Length' => [
'min' => 1,
'max' => 30,
'allowEmptyString' => TRUE
'max' => 30
],
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct(ConfigFactoryInterface $config_factory, LogMessagePa
/**
* {@inheritdoc}
*/
public function log($level, $message, array $context = []) {
public function log($level, $message, array $context = []): void {
// Only log messages from our debug module.
if ($context['channel'] === 'apigee_edge_debug') {
parent::log($level, $message, $context);
Expand All @@ -71,6 +71,7 @@ protected function syslogWrapper($level, $entry) {
$log_path = \Drupal::service('file_system')->realpath('public://');
}
// Add test prefix to the log file.
// @phpstan-ignore-next-line
$log_path .= '/apigee_edge_debug-' . str_replace('test', '', $this->database->tablePrefix()) . '.log';
// Do not fail a test just because the fail is not writable.
@error_log($entry . PHP_EOL, 3, $log_path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ protected function syslogWrapper($level, $entry) {
$log_path = \Drupal::service('file_system')->realpath('public://');
}
// Add test id as a suffix to the log file.
// @todo tablePrefix() is deprecated in Drupal 10.1
// @phpstan-ignore-next-line
$log_path .= '/syslog-' . str_replace('test', '', $this->database->tablePrefix()) . '.log';
// Do not fail a test just because the fail is not writable.
@error_log($entry . PHP_EOL, 3, $log_path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ function apigee_edge_test_app_keys_developer_app_insert(EntityInterface $entity)
$dacc->create("{$prefix}-{$random->name()}", "{$prefix}-{$random->name()}");
}
catch (ApiException $e) {
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
// @phpstan-ignore-next-line
watchdog_exception('apigee_edge', $e, 'Unable to create new API key on Apigee Edge for @app app. !message', ['@app' => $entity->id()]);
}
}
catch (ApiException $e) {
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
// @phpstan-ignore-next-line
watchdog_exception('apigee_edge', $e, 'Unable to delete auto-generated key of @app app on Apigee Edge. !message', ['@app' => $entity->id()]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,28 @@ public function overrideAppKeyOnGenerate(AppCredentialGenerateEvent $event) {
$credential_controller->addProducts($new_consumer_key, $products);
}
catch (ApiException $e) {
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
// @phpstan-ignore-next-line
watchdog_exception('apigee_edge', $e, 'Unable to assign API products to the newly generated API key on Apigee Edge for @app app. !message', ['@app' => "{$event->getOwnerId()}:{$event->getAppName()}"]);
try {
$credential_controller->delete($new_consumer_key);
}
catch (ApiException $e) {
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
// @phpstan-ignore-next-line
watchdog_exception('apigee_edge', $e, 'Unable to delete newly generated API key after API product re-association has failed on Apigee Edge for @app app. !message', ['@app' => "{$event->getOwnerId()}:{$event->getAppName()}"]);
}
}
}
catch (ApiException $e) {
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
// @phpstan-ignore-next-line
watchdog_exception('apigee_edge', $e, 'Unable to create new API key on Apigee Edge for @app app. !message', ['@app' => "{$event->getOwnerId()}:{$event->getAppName()}"]);
}
}
catch (ApiException $e) {
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
// @phpstan-ignore-next-line
watchdog_exception('apigee_edge', $e, 'Unable to delete auto-generated key of @app app on Apigee Edge. !message', ['@app' => "{$event->getOwnerId()}:{$event->getAppName()}"]);
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/src/Functional/DeveloperAppPermissionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ public function testPermissions() {
*/
protected function revokeDefaultAuthUserPermissions() {
$definition = $this->entityType;
// @todo user_role_permissions() is deprecated for Drupal 10.1 https://www.drupal.org/node/3348138
// @phpstan-ignore-next-line
$user_permissions = user_role_permissions([RoleInterface::AUTHENTICATED_ID]);
$authenticated_user_permissions = array_filter($user_permissions[RoleInterface::AUTHENTICATED_ID], function ($perm) use ($definition) {
return preg_match("/own {$definition->id()}$/", $perm);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public function createScreenshot($filename_prefix = '', $set_background_color =
}
/** @var \Drupal\Core\Database\Connection $database */
$database = $this->container->get('database');
// @todo tablePrefix() is deprecated in Drupal 10.1
// @phpstan-ignore-next-line
$test_id = str_replace('test', '', $database->tablePrefix());
// Add table suffix (test id) to the file name and ensure the generated
// file name is unique.
Expand Down
2 changes: 2 additions & 0 deletions tests/src/Kernel/ApigeeEdgeKernelTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ trait ApigeeEdgeKernelTestTrait {
*/
protected function logException(\Exception $exception, string $suffix = '') {
$ro = new \ReflectionObject($this);
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
// @phpstan-ignore-next-line
watchdog_exception("{$ro->getShortName()}{$suffix}", $exception);
}

Expand Down
4 changes: 4 additions & 0 deletions tests/src/Kernel/MockIntegrationToggleKernelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public function testIntegrationToggleOff() {

$this->enableModules(['apigee_mock_api_client']);

// @todo getConfig() is deprecated and will be removed in guzzlehttp/guzzle:8.0
// @phpstan-ignore-next-line
$handler = $this->container
->get('apigee_mock_api_client.mock_http_client_factory')
->fromOptions([])
Expand All @@ -95,6 +97,8 @@ public function testIntegrationToggleOn() {

$this->enableModules(['apigee_mock_api_client']);

// @todo getConfig() is deprecated and will be removed in guzzlehttp/guzzle:8.0
// @phpstan-ignore-next-line
$handler = $this->container
->get('apigee_mock_api_client.mock_http_client_factory')
->fromOptions([])
Expand Down
2 changes: 2 additions & 0 deletions tests/src/Kernel/UserCreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ protected function tearDown(): void {
catch (\Exception $exception) {
$this->logException($exception);
}

parent::tearDown();
}

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/src/Kernel/Util/ApigeeEdgeManagementCliServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ protected function tearDown(): void {
}
}
catch (\Exception $exception) {
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
// @phpstan-ignore-next-line
watchdog_exception('apigee_edge', $exception);
}

Expand Down
2 changes: 2 additions & 0 deletions tests/src/Traits/ApigeeEdgeFunctionalTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ protected static function fixUrl(string $url): string {
*/
protected function logException(\Exception $exception, string $suffix = '') {
$ro = new \ReflectionObject($this);
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
// @phpstan-ignore-next-line
watchdog_exception("{$ro->getShortName()}{$suffix}", $exception);
}

Expand Down
Loading
Loading