From 18761b4627ff77899776e1f2119192e1b41a00ec Mon Sep 17 00:00:00 2001 From: Adam Nagy Date: Mon, 13 Jan 2025 12:42:01 +0100 Subject: [PATCH 1/3] EWPP-4991: Ensure PHP8.3 compatibility. --- .drone.yml | 14 +++++++------- composer.json | 2 +- docker-compose.yml | 7 +++---- .../src/Drush/Commands/BannerCommands.php | 7 ++++--- .../src/Drush/Commands/CarouselCommands.php | 7 ++++--- oe_paragraphs.behat.inc | 2 +- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/.drone.yml b/.drone.yml index 9412a480..2951b8df 100644 --- a/.drone.yml +++ b/.drone.yml @@ -21,8 +21,8 @@ services: - DRUPAL_SPARQL_HOSTNAME=sparql - DRUPAL_SPARQL_PORT=8890 mysql: - image: git.fpfis.tech.ec.europa.eu/fpfis/dependency_proxy/containers/percona:5.7 - command: --innodb-log-file-size=1G --max_allowed_packet=1G --innodb-buffer-pool-size=512M --wait_timeout=3000 --net_write_timeout=3000 --log_error_verbosity=3 + image: git.fpfis.tech.ec.europa.eu/fpfis/dependency_proxy/containers/percona:8.0 + command: --innodb-log-file-size=1G --max_allowed_packet=1G --innodb-buffer-pool-size=512M --wait_timeout=3000 --net_write_timeout=3000 --log_error_verbosity=3 --skip-log-bin --innodb-flush-log-at-trx-commit=2 --innodb-read-io-threads=16 --innodb-write-io-threads=16 environment: - MYSQL_ALLOW_EMPTY_PASSWORD=yes selenium: @@ -98,11 +98,11 @@ pipeline: matrix: include: - - CORE_VERSION: 10.2.0 - PHP_VERSION: 8.1 - - CORE_VERSION: 10.2.0 - PHP_VERSION: 8.2 - CORE_VERSION: 10.3.0 PHP_VERSION: 8.1 - CORE_VERSION: 10.3.0 - PHP_VERSION: 8.2 + PHP_VERSION: 8.3 + - CORE_VERSION: 10.4.0 + PHP_VERSION: 8.1 + - CORE_VERSION: 10.4.0 + PHP_VERSION: 8.3 diff --git a/composer.json b/composer.json index 893962a4..8b6adeac 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "openeuropa/oe_media": "^1.23.1", "openeuropa/oe_webtools": "^1.22", "openeuropa/rdf_skos": "^1.0.0-alpha10", - "openeuropa/task-runner-drupal-project-symlink": "^1.0-beta6", + "openeuropa/task-runner-drupal-project-symlink": "^1.0", "phpspec/prophecy-phpunit": "^2", "symfony/phpunit-bridge": "^6.0" }, diff --git a/docker-compose.yml b/docker-compose.yml index f0e7f7b0..af9cffdf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,6 @@ -version: '2' services: web: - image: fpfis/httpd-php-dev:8.1 + image: fpfis/httpd-php-dev:8.3 working_dir: /var/www/html ports: - 8080:8080 @@ -17,8 +16,8 @@ services: # Enable step debugging for all PHP request. See ./README.md#step-debugging for more information. # XDEBUG_SESSION: 1 mysql: - image: percona/percona-server:5.7 - command: --innodb-log-file-size=1G --max_allowed_packet=1G --innodb-buffer-pool-size=512M --wait_timeout=3000 --net_write_timeout=3000 --log_error_verbosity=3 + image: percona/percona-server:8.0 + command: --innodb-log-file-size=1G --max_allowed_packet=1G --innodb-buffer-pool-size=512M --wait_timeout=3000 --net_write_timeout=3000 --log_error_verbosity=3 --skip-log-bin --innodb-flush-log-at-trx-commit=2 --innodb-read-io-threads=16 --innodb-write-io-threads=16 environment: MYSQL_ALLOW_EMPTY_PASSWORD: "yes" # ports: diff --git a/modules/oe_paragraphs_banner/src/Drush/Commands/BannerCommands.php b/modules/oe_paragraphs_banner/src/Drush/Commands/BannerCommands.php index ee37dc5b..d3e977dc 100644 --- a/modules/oe_paragraphs_banner/src/Drush/Commands/BannerCommands.php +++ b/modules/oe_paragraphs_banner/src/Drush/Commands/BannerCommands.php @@ -4,13 +4,14 @@ namespace Drupal\oe_paragraphs_banner\Drush\Commands; +use CLI\Usage; +use CLI\Command; use Drupal\Core\Batch\BatchBuilder; use Drupal\Core\DependencyInjection\DependencySerializationTrait; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\oe_paragraphs_banner\BannerParagraphUpdater; -use Drush\Attributes as CLI; use Drush\Commands\DrushCommands; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -76,8 +77,8 @@ public static function create(ContainerInterface $container): BannerCommands { /** * Triggers the update of the Banner paragraph data. */ - #[CLI\Command(name: 'oe-paragraphs-update-banner-data:run', aliases: [])] - #[CLI\Usage(name: 'oe-paragraphs-update-banner-data:run', description: 'Updates Banner paragraph data.')] + #[Command(name: 'oe-paragraphs-update-banner-data:run', aliases: [])] + #[Usage(name: 'oe-paragraphs-update-banner-data:run', description: 'Updates Banner paragraph data.')] public function updateBannerData(): void { $ids = $this->entityTypeManager->getStorage('paragraph')->getQuery() ->condition('type', 'oe_banner') diff --git a/modules/oe_paragraphs_carousel/src/Drush/Commands/CarouselCommands.php b/modules/oe_paragraphs_carousel/src/Drush/Commands/CarouselCommands.php index 3c0f5471..afac24d6 100644 --- a/modules/oe_paragraphs_carousel/src/Drush/Commands/CarouselCommands.php +++ b/modules/oe_paragraphs_carousel/src/Drush/Commands/CarouselCommands.php @@ -4,13 +4,14 @@ namespace Drupal\oe_paragraphs_carousel\Drush\Commands; +use CLI\Usage; +use CLI\Command; use Drupal\Core\Batch\BatchBuilder; use Drupal\Core\DependencyInjection\DependencySerializationTrait; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\oe_paragraphs_carousel\CarouselParagraphUpdater; -use Drush\Attributes as CLI; use Drush\Commands\DrushCommands; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -74,8 +75,8 @@ public static function create(ContainerInterface $container): CarouselCommands { /** * Triggers the update of the Carousel paragraph data. */ - #[CLI\Command(name: 'oe-paragraphs-update-carousel-data:run', aliases: [])] - #[CLI\Usage(name: 'oe-paragraphs-update-carousel-data:run', description: 'Updates Carousel paragraph data.')] + #[Command(name: 'oe-paragraphs-update-carousel-data:run', aliases: [])] + #[Usage(name: 'oe-paragraphs-update-carousel-data:run', description: 'Updates Carousel paragraph data.')] public function updateCarouselData(): void { $ids = $this->entityTypeManager->getStorage('paragraph')->getQuery() ->condition('type', 'oe_carousel') diff --git a/oe_paragraphs.behat.inc b/oe_paragraphs.behat.inc index f4b3d262..c7939903 100644 --- a/oe_paragraphs.behat.inc +++ b/oe_paragraphs.behat.inc @@ -64,7 +64,7 @@ class OeParagraphsSubContext extends DrupalSubContextBase { // Only check fields that reference paragraph types. if ($this->getEntityReferenceTargetEntityId($entity, $field_name) !== 'paragraph') { continue; - }; + } $actual_par_type_ids = $this->getEntityReferenceTargetBundles($entity, $field_name); From 5af43ac1621d064bd97c760e6d15767ed994e3cc Mon Sep 17 00:00:00 2001 From: Adam Nagy Date: Mon, 13 Jan 2025 14:20:32 +0100 Subject: [PATCH 2/3] EWPP-4991: Temp fix phpcs issue. --- .../src/Drush/Commands/BannerCommands.php | 10 ++++++---- .../src/Drush/Commands/CarouselCommands.php | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/oe_paragraphs_banner/src/Drush/Commands/BannerCommands.php b/modules/oe_paragraphs_banner/src/Drush/Commands/BannerCommands.php index d3e977dc..98fbda76 100644 --- a/modules/oe_paragraphs_banner/src/Drush/Commands/BannerCommands.php +++ b/modules/oe_paragraphs_banner/src/Drush/Commands/BannerCommands.php @@ -4,14 +4,13 @@ namespace Drupal\oe_paragraphs_banner\Drush\Commands; -use CLI\Usage; -use CLI\Command; use Drupal\Core\Batch\BatchBuilder; use Drupal\Core\DependencyInjection\DependencySerializationTrait; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\oe_paragraphs_banner\BannerParagraphUpdater; +use Drush\Attributes as CLI; use Drush\Commands\DrushCommands; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -76,10 +75,13 @@ public static function create(ContainerInterface $container): BannerCommands { /** * Triggers the update of the Banner paragraph data. + * + * phpcs:disable */ - #[Command(name: 'oe-paragraphs-update-banner-data:run', aliases: [])] - #[Usage(name: 'oe-paragraphs-update-banner-data:run', description: 'Updates Banner paragraph data.')] + #[CLI\Command(name: 'oe-paragraphs-update-banner-data:run', aliases: [])] + #[CLI\Usage(name: 'oe-paragraphs-update-banner-data:run', description: 'Updates Banner paragraph data.')] public function updateBannerData(): void { + // phpcs:enable $ids = $this->entityTypeManager->getStorage('paragraph')->getQuery() ->condition('type', 'oe_banner') ->exists('field_oe_banner_type') diff --git a/modules/oe_paragraphs_carousel/src/Drush/Commands/CarouselCommands.php b/modules/oe_paragraphs_carousel/src/Drush/Commands/CarouselCommands.php index afac24d6..881a8959 100644 --- a/modules/oe_paragraphs_carousel/src/Drush/Commands/CarouselCommands.php +++ b/modules/oe_paragraphs_carousel/src/Drush/Commands/CarouselCommands.php @@ -4,14 +4,13 @@ namespace Drupal\oe_paragraphs_carousel\Drush\Commands; -use CLI\Usage; -use CLI\Command; use Drupal\Core\Batch\BatchBuilder; use Drupal\Core\DependencyInjection\DependencySerializationTrait; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\oe_paragraphs_carousel\CarouselParagraphUpdater; +use Drush\Attributes as CLI; use Drush\Commands\DrushCommands; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -74,10 +73,13 @@ public static function create(ContainerInterface $container): CarouselCommands { /** * Triggers the update of the Carousel paragraph data. + * + * phpcs:disable */ - #[Command(name: 'oe-paragraphs-update-carousel-data:run', aliases: [])] - #[Usage(name: 'oe-paragraphs-update-carousel-data:run', description: 'Updates Carousel paragraph data.')] + #[CLI\Command(name: 'oe-paragraphs-update-carousel-data:run', aliases: [])] + #[CLI\Usage(name: 'oe-paragraphs-update-carousel-data:run', description: 'Updates Carousel paragraph data.')] public function updateCarouselData(): void { + // phpcs:enable $ids = $this->entityTypeManager->getStorage('paragraph')->getQuery() ->condition('type', 'oe_carousel') ->allRevisions() From e9c15d40ee09dc27b1b4b969066de0dbd139f370 Mon Sep 17 00:00:00 2001 From: Adam Nagy Date: Mon, 13 Jan 2025 16:24:35 +0100 Subject: [PATCH 3/3] EWPP-4991: Remove composer patching for 10.2. --- .drone.yml | 14 -------- composer.json | 17 ++++++---- ...age.paragraph.field_oe_plain_text_long.yml | 2 +- grumphp.yml.dist | 33 ++++--------------- oe_paragraphs.install | 8 ++--- phpstan.neon.dist | 2 ++ .../FieldWidget/ParagraphVariantsWidget.php | 4 ++- tests/Traits/TraversingTrait.php | 3 +- 8 files changed, 29 insertions(+), 54 deletions(-) create mode 100644 phpstan.neon.dist diff --git a/.drone.yml b/.drone.yml index 2951b8df..1dabd048 100644 --- a/.drone.yml +++ b/.drone.yml @@ -42,20 +42,6 @@ services: - DBA_PASSWORD=dba pipeline: - composer-change-patch: - group: warmup - image: registry.fpfis.eu/fpfis/httpd-php:${PHP_VERSION}-ci - volumes: - - /cache:/cache - commands: - # Ignore the patch for 10.2.x. - - > - composer config --merge --json "extra.patches-ignore.drupal/media_avportal" '{"drupal/remote_stream_wrapper": {"Drupal 10.3.x only - see media_avportal/README.md for 10.2.x - https://www.drupal.org/project/remote_stream_wrapper/issues/3437974": "https://www.drupal.org/files/issues/2024-06-21/drupal_10_3_deliver_signature_change-3437974-2_0_0-18.patch"}}' - when: - matrix: - CORE_VERSION: "10.2.0" - - composer-install: group: prepare image: registry.fpfis.eu/fpfis/httpd-php:${PHP_VERSION}-ci diff --git a/composer.json b/composer.json index 8b6adeac..3673460f 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "drush/drush": "^12", "nikic/php-parser": "^4", "openeuropa/behat-transformation-context": "^0.1", - "openeuropa/code-review": "^2.0", + "openeuropa/code-review-drupal": "^1.0.0-alpha", "openeuropa/oe_content": "^3.0.0", "openeuropa/oe_media": "^1.23.1", "openeuropa/oe_webtools": "^1.22", @@ -80,13 +80,17 @@ ] }, "repositories": [ - { - "type": "vcs", - "url": "https://git.drupalcode.org/project/description_list_field.git" - }, { "type": "composer", "url": "https://packages.drupal.org/8" + }, + { + "type": "git", + "url": "https://github.com/openeuropa/DrupalDriver.git" + }, + { + "type": "git", + "url": "https://github.com/openeuropa/code-review-drupal.git" } ], "config": { @@ -94,10 +98,11 @@ "discard-changes": true, "allow-plugins": { "composer/installers": true, - "drupal/core-composer-scaffold": true, "cweagans/composer-patches": true, "dealerdirect/phpcodesniffer-composer-installer": true, + "drupal/core-composer-scaffold": true, "phpro/grumphp": true, + "phpro/grumphp-shim": true, "phpstan/extension-installer": true } } diff --git a/config/install/field.storage.paragraph.field_oe_plain_text_long.yml b/config/install/field.storage.paragraph.field_oe_plain_text_long.yml index 2d725c9f..c0075aa5 100644 --- a/config/install/field.storage.paragraph.field_oe_plain_text_long.yml +++ b/config/install/field.storage.paragraph.field_oe_plain_text_long.yml @@ -15,4 +15,4 @@ cardinality: 1 translatable: true indexes: { } persist_with_no_fields: false -custom_storage: false \ No newline at end of file +custom_storage: false diff --git a/grumphp.yml.dist b/grumphp.yml.dist index ca8e793b..af65fba5 100644 --- a/grumphp.yml.dist +++ b/grumphp.yml.dist @@ -1,31 +1,12 @@ imports: - - { resource: vendor/openeuropa/code-review/dist/drupal-conventions.yml } -parameters: - tasks.phpcs.ignore_patterns: - - vendor/ - - build/ - tasks.phpcs.triggered_by: - - php - - module - - inc - - theme - - install - - extra_tasks: + - { resource: ./vendor/openeuropa/code-review-drupal/dist/oe-component-conventions.yml } +grumphp: + tasks: phpparser: ignore_patterns: - vendor/ - - build/ - visitors: - declare_strict_types: ~ - triggered_by: - - php - - module - - inc - - theme - - install -grumphp: - extensions: - - OpenEuropa\CodeReview\ExtraTasksExtension git_hook_variables: - EXEC_GRUMPHP_COMMAND: 'docker-compose exec -T web' + EXEC_GRUMPHP_COMMAND: 'docker-compose exec -T web' + +parameters: + tasks.phpstan.configuration: phpstan.neon.dist diff --git a/oe_paragraphs.install b/oe_paragraphs.install index f2f4ed82..ed843906 100755 --- a/oe_paragraphs.install +++ b/oe_paragraphs.install @@ -26,7 +26,7 @@ function oe_paragraphs_update_8001(array &$sandbox): void { 'oe_list_item_block' => 'field_oe_list_item_block_variant', 'oe_list_item' => 'field_oe_list_item_variant', ]; - $paragraph_ids = []; + $sandbox['paragraph_ids'] = []; foreach ($sandbox['variant_fields'] as $bundle => $field) { // Make sure we have the old fields in the database. @@ -40,11 +40,11 @@ function oe_paragraphs_update_8001(array &$sandbox): void { $query->exists($field); $result = $query->execute(); if (!empty($result)) { - $paragraph_ids += $result; + $sandbox['paragraph_ids'] += $result; } } - $sandbox['total'] = count($paragraph_ids); + $sandbox['total'] = count($sandbox['paragraph_ids']); $sandbox['current'] = 0; $sandbox['paragraphs_per_batch'] = 25; @@ -139,7 +139,7 @@ function oe_paragraphs_update_8001(array &$sandbox): void { } // Get the current slice of paragraph ids. - $pids = array_slice($paragraph_ids, $sandbox['current'], $sandbox['paragraphs_per_batch']); + $pids = array_slice($sandbox['paragraph_ids'], $sandbox['current'], $sandbox['paragraphs_per_batch']); $entity_storage = \Drupal::entityTypeManager()->getStorage('paragraph'); foreach ($pids as $pid) { diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 00000000..ca9247ac --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,2 @@ +includes: + - ./vendor/openeuropa/code-review-drupal/dist/phpstan.drupal.neon diff --git a/src/Plugin/Field/FieldWidget/ParagraphVariantsWidget.php b/src/Plugin/Field/FieldWidget/ParagraphVariantsWidget.php index 0d329ffe..c4f862bc 100644 --- a/src/Plugin/Field/FieldWidget/ParagraphVariantsWidget.php +++ b/src/Plugin/Field/FieldWidget/ParagraphVariantsWidget.php @@ -414,7 +414,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen $context = [ 'form' => $form, - 'widget' => self::getWidgetState($parents, $field_name, $form_state, $widget_state), + 'widget' => self::getWidgetState($parents, $field_name, $form_state), 'items' => $items, 'delta' => $delta, 'element' => $element, @@ -470,8 +470,10 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen 'mode' => $display->getMode(), ]; + // @phpstan-ignore-next-line field_group_attach_groups($element['subform'], $context); $element['subform']['#process'][] = [ + // @phpstan-ignore-next-line FormatterHelper::class, 'formProcess', ]; diff --git a/tests/Traits/TraversingTrait.php b/tests/Traits/TraversingTrait.php index 789d171c..287e0c0f 100644 --- a/tests/Traits/TraversingTrait.php +++ b/tests/Traits/TraversingTrait.php @@ -23,8 +23,7 @@ trait TraversingTrait { * @throws \Exception * Thrown when no select field is found. */ - protected function findSelect($select): NodeElement { - /** @var \Behat\Mink\Element\NodeElement $element */ + protected function findSelect(string $select): NodeElement { $element = $this->getSession()->getPage()->find('named', ['select', $select]); if (empty($element)) {