From e40ad4677487788d470a09ef3e657ae77eb63dd6 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Fri, 28 Jul 2023 17:39:18 +0200 Subject: [PATCH 1/5] EWPP-3512: drush.services.yml is mandatory with Drush 12. --- composer.json | 5 +++++ modules/oe_authentication_user_fields/drush.services.yml | 6 ++++++ .../oe_authentication_user_fields.services.yml | 5 ----- 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 modules/oe_authentication_user_fields/drush.services.yml diff --git a/composer.json b/composer.json index bc75646..9388157 100644 --- a/composer.json +++ b/composer.json @@ -61,6 +61,11 @@ "locations": { "web-root": "./build" } + }, + "drush": { + "services": { + "drush.services.yml": "^11" + } } }, "config": { diff --git a/modules/oe_authentication_user_fields/drush.services.yml b/modules/oe_authentication_user_fields/drush.services.yml new file mode 100644 index 0000000..61dabb3 --- /dev/null +++ b/modules/oe_authentication_user_fields/drush.services.yml @@ -0,0 +1,6 @@ +services: + oe_authentication_user_fields.sanitize_commands: + class: Drupal\oe_authentication_user_fields\Commands\sql\UserSanitizeCommand + arguments: [ '@entity_type.manager', '@database' ] + tags: + - { name: drush.command } diff --git a/modules/oe_authentication_user_fields/oe_authentication_user_fields.services.yml b/modules/oe_authentication_user_fields/oe_authentication_user_fields.services.yml index 6a44bde..ff9baf3 100755 --- a/modules/oe_authentication_user_fields/oe_authentication_user_fields.services.yml +++ b/modules/oe_authentication_user_fields/oe_authentication_user_fields.services.yml @@ -3,8 +3,3 @@ services: class: Drupal\oe_authentication_user_fields\EventSubscriber\EuLoginAttributesToUserFieldsSubscriber tags: - { name: event_subscriber } - oe_authentication_user_fields.sanitize_commands: - class: Drupal\oe_authentication_user_fields\Commands\sql\UserSanitizeCommand - arguments: ['@entity_type.manager', '@database'] - tags: - - { name: drush.command } From 51ce21d8e23fdae823a299ee76a29ce9f5c4aa90 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Fri, 28 Jul 2023 17:58:04 +0200 Subject: [PATCH 2/5] EWPP-3512: Fix coding standards. --- .../src/Commands/sql/UserSanitizeCommand.php | 4 ++-- src/Event/EuLoginEventSubscriber.php | 2 +- tests/Behat/AuthenticationContext.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/oe_authentication_user_fields/src/Commands/sql/UserSanitizeCommand.php b/modules/oe_authentication_user_fields/src/Commands/sql/UserSanitizeCommand.php index 320d602..190412b 100755 --- a/modules/oe_authentication_user_fields/src/Commands/sql/UserSanitizeCommand.php +++ b/modules/oe_authentication_user_fields/src/Commands/sql/UserSanitizeCommand.php @@ -4,12 +4,12 @@ namespace Drupal\oe_authentication_user_fields\Commands\sql; +use Consolidation\AnnotatedCommand\CommandData; use Drupal\Core\Database\Connection; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drush\Commands\DrushCommands; use Drush\Drupal\Commands\sql\SanitizePluginInterface; -use Consolidation\AnnotatedCommand\CommandData; use Symfony\Component\Console\Input\InputInterface; -use Drupal\Core\Entity\EntityTypeManagerInterface; /** * Sanitizes the user fields related data. diff --git a/src/Event/EuLoginEventSubscriber.php b/src/Event/EuLoginEventSubscriber.php index 48c26e7..8611408 100644 --- a/src/Event/EuLoginEventSubscriber.php +++ b/src/Event/EuLoginEventSubscriber.php @@ -11,10 +11,10 @@ use Drupal\cas\Service\CasHelper; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\oe_authentication\CasProcessor; use Drupal\user\UserInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Drupal\oe_authentication\CasProcessor; /** * Event subscriber for CAS module events. diff --git a/tests/Behat/AuthenticationContext.php b/tests/Behat/AuthenticationContext.php index 035bdf6..0053674 100644 --- a/tests/Behat/AuthenticationContext.php +++ b/tests/Behat/AuthenticationContext.php @@ -4,9 +4,9 @@ namespace Drupal\Tests\oe_authentication\Behat; -use Drupal\user\Entity\User; use Behat\Behat\Hook\Scope\BeforeScenarioScope; use Drupal\DrupalExtension\Context\RawDrupalContext; +use Drupal\user\Entity\User; use Drupal\user\UserInterface; /** From 6542b62ca5e656e8f0d7a1dfddee699f90df7975 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Fri, 28 Jul 2023 17:59:39 +0200 Subject: [PATCH 3/5] EWPP-3512: Operation order changed when using drush.services.yml. --- .../tests/src/Functional/UserSanitizeCommandTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/oe_authentication_user_fields/tests/src/Functional/UserSanitizeCommandTest.php b/modules/oe_authentication_user_fields/tests/src/Functional/UserSanitizeCommandTest.php index 1337188..67cc38e 100755 --- a/modules/oe_authentication_user_fields/tests/src/Functional/UserSanitizeCommandTest.php +++ b/modules/oe_authentication_user_fields/tests/src/Functional/UserSanitizeCommandTest.php @@ -46,11 +46,11 @@ public function testEuLoginUsersDataSanitization() { $this->drush('sql:sanitize'); $expected = 'The following operations will be performed:' . PHP_EOL . PHP_EOL; - $expected .= '* Sanitise user fields.' . PHP_EOL; $expected .= '* Truncate sessions table.' . PHP_EOL; $expected .= '* Sanitize text fields associated with users.' . PHP_EOL; $expected .= '* Sanitize user passwords.' . PHP_EOL; - $expected .= '* Sanitize user emails.'; + $expected .= '* Sanitize user emails.' . PHP_EOL; + $expected .= '* Sanitise user fields.'; $this->assertOutputEquals($expected); $user = \Drupal::entityTypeManager()->getStorage('user')->load($user->id()); From 7c8b611cb7b44e66bcc70faad9d726955d876b2e Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Fri, 28 Jul 2023 18:33:18 +0200 Subject: [PATCH 4/5] EWPP-3512: Output changes when executing in Drupal 9 and 10. --- .../tests/src/Functional/UserSanitizeCommandTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/oe_authentication_user_fields/tests/src/Functional/UserSanitizeCommandTest.php b/modules/oe_authentication_user_fields/tests/src/Functional/UserSanitizeCommandTest.php index 67cc38e..0daa101 100755 --- a/modules/oe_authentication_user_fields/tests/src/Functional/UserSanitizeCommandTest.php +++ b/modules/oe_authentication_user_fields/tests/src/Functional/UserSanitizeCommandTest.php @@ -45,7 +45,10 @@ public function testEuLoginUsersDataSanitization() { ]); $this->drush('sql:sanitize'); - $expected = 'The following operations will be performed:' . PHP_EOL . PHP_EOL; + $expected = 'The following operations will be performed:' . PHP_EOL; + // An extra newline is added when the command is executed with Drupal 9.x. + // @todo Remove when support for Drupal 9.x is dropped. + $expected .= version_compare(\Drupal::VERSION, '10.0.0', '<') ? PHP_EOL : ''; $expected .= '* Truncate sessions table.' . PHP_EOL; $expected .= '* Sanitize text fields associated with users.' . PHP_EOL; $expected .= '* Sanitize user passwords.' . PHP_EOL; From 810cf57a27892d3934f78df9d984cb948e4b8a7d Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Mon, 31 Jul 2023 10:00:09 +0200 Subject: [PATCH 5/5] EWPP-3512: Allow Drush 12. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9388157..99579e9 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "drupal/cas_mock_server": "^2.0.1", "drupal/core-composer-scaffold": "^9.4 || ^10", "drupal/drupal-extension": "^5.0", - "drush/drush": "^11.1", + "drush/drush": "^11.1 || ^12", "mikey179/vfsstream": "^1.6.10", "openeuropa/behat-transformation-context": "^0.2", "openeuropa/code-review": "^2.0.0-alpha6",