From 0e7c34c2923d063df4686a626adf58e10a3ccbc1 Mon Sep 17 00:00:00 2001 From: 22Alexandra Date: Wed, 2 Feb 2022 15:50:04 +0200 Subject: [PATCH 1/4] EWPP-1912: Update to PHP8 and Composer v2. --- .drone.yml | 15 ++++-- composer.json | 53 ++++++++++++++----- docker-compose.yml | 3 +- grumphp.yml.dist | 19 +++++-- .../oe_editorial_content_lock.info.yml | 2 +- ...orate_workflow_translation_poetry.info.yml | 2 +- ...al_corporate_workflow_translation.info.yml | 2 +- ...rporate_workflow_translation_test.info.yml | 2 +- ...rporateWorkflowTranslationRevisionTest.php | 0 .../CorporateWorkflowTranslationDropTest.php | 0 .../CorporateWorkflowTranslationTest.php | 0 .../oe_editorial_corporate_workflow.info.yml | 2 +- .../src/Traits/CorporateWorkflowTrait.php | 6 +-- .../oe_editorial_entity_version.info.yml | 2 +- .../oe_editorial_entity_version.install | 2 +- .../oe_editorial_unpublish.info.yml | 2 +- .../src/Form/ContentEntityUnpublishForm.php | 2 +- .../oe_editorial_unpublish_test.info.yml | 2 +- .../oe_editorial_workflow_demo.info.yml | 2 +- .../oe_editorial_workflow_demo.install | 2 +- oe_editorial.info.yml | 2 +- 21 files changed, 83 insertions(+), 39 deletions(-) rename modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/{ => src}/Functional/CorporateWorkflowTranslationRevisionTest.php (100%) rename modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/{ => src}/FunctionalJavascript/CorporateWorkflowTranslationDropTest.php (100%) rename modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/{ => src}/Kernel/CorporateWorkflowTranslationTest.php (100%) diff --git a/.drone.yml b/.drone.yml index bade934..7e6a406 100644 --- a/.drone.yml +++ b/.drone.yml @@ -17,6 +17,7 @@ services: image: registry.fpfis.eu/fpfis/httpd-php:${PHP_VERSION}-ci environment: &web-environment - DOCUMENT_ROOT=/test/oe_editorial + - COMPOSERVER=--2 - POETRY_IDENTIFIER_SEQUENCE=NEXT_EUROPA_COUNTER - POETRY_SERVICE_ENDPOINT=http://web:8080/build/poetry-mock/wsdl - POETRY_SERVICE_USERNAME=admin @@ -41,13 +42,17 @@ services: - NODE_MAX_SESSION=5 pipeline: - composer-install: + composer-install-highest: group: prepare image: registry.fpfis.eu/fpfis/httpd-php:${PHP_VERSION}-ci volumes: - /cache/${DRONE_REPO_NAME}:/cache commands: - - composer install --ansi --no-suggest --no-progress + - composer self-update --2 + - composer install --ansi --no-progress + when: + matrix: + COMPOSER_BOUNDARY: highest composer-update-lowest: group: post-prepare @@ -57,7 +62,7 @@ pipeline: commands: # @todo remove "composer install" step once the following issue is fixed. # @link https://webgate.ec.europa.eu/CITnet/jira/browse/OPENEUROPA-1234 - - composer update --prefer-lowest --prefer-stable --ansi --no-suggest --no-progress --no-interaction + - composer update --prefer-lowest --prefer-stable --ansi --no-progress --no-interaction when: matrix: COMPOSER_BOUNDARY: lowest @@ -65,6 +70,7 @@ pipeline: site-install: image: registry.fpfis.eu/fpfis/httpd-php:${PHP_VERSION}-ci commands: + - while ! mysqladmin ping -h mysql --silent; do sleep 1; done - ./vendor/bin/run drupal:site-install grumphp: @@ -99,4 +105,5 @@ matrix: - lowest - highest PHP_VERSION: - - 7.3 + - 7.4 + - 8.0 diff --git a/composer.json b/composer.json index 700fb49..857464b 100644 --- a/composer.json +++ b/composer.json @@ -6,35 +6,53 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "php": ">=7.3", - "drupal/core": "^8.9 || ^9.1" + "php": ">=7.4", + "drupal/core": "^9.2" }, "require-dev": { + "behat/behat": "^3.10", + "behat/mink-extension": "^2.3.1", "composer/installers": "^1.5", - "drupal/core-composer-scaffold": "^8.9 || ^9.1", + "drupal/address": "^1.8", "drupal/config_devel": "^1.2", "drupal/content_lock": "^2.2", + "drupal/core-composer-scaffold": "^9.2", + "drupal/core-dev": "^9.2", + "drupal/ctools": "^3.7", "drupal/drupal-extension": "^4.0", - "drupal/entity_version": "^1.0-beta8", - "drupal/address": "^1.8", - "openeuropa/oe_paragraphs": "^1.10", + "drupal/entity_version": "dev-EWPP-1912", + "drupal/token": "^1.10", "drush/drush": "^10.3", "ec-europa/oe-poetry-client": "dev-master", + "egulias/email-validator": "^2.1.22 || ^3.0", "instaclick/php-webdriver": "^1.4.7", - "nikic/php-parser": "^3.1.5 || ^4", + "nikic/php-parser": "^4.12.0", "openeuropa/behat-transformation-context": "~0.1", - "openeuropa/code-review": "^1.7", - "openeuropa/drupal-core-require-dev": "^8.9 || ^9.1", - "openeuropa/oe_multilingual": "^1.5", - "openeuropa/oe_translation": "dev-master", - "openeuropa/task-runner-drupal-project-symlink": "^1.0", - "phpspec/prophecy-phpunit": "^1 || ^2" + "openeuropa/code-review": "^2.0", + "openeuropa/oe_multilingual": "^1.10", + "openeuropa/oe_paragraphs": "^1.10", + "openeuropa/oe_translation": "dev-EWPP-1908", + "openeuropa/task-runner-drupal-project-symlink": "^1.0-beta5", + "phpspec/prophecy-phpunit": "^2", + "symfony/dom-crawler": "^4.4.12" }, + "_readme": [ + "Explicit requirement for private repository of entity_version contrib module until next release.", + "Explicit minimum version requirement of drupal/ctools module due to D9.2 compatability.", + "Explicit requirement for egulias/email-validator due to https://www.drupal.org/project/drupal/issues/3061074#comment-14300579. It can be removed when Drupal core 9.2 support is droppped.", + "Explicit requirement of drupal/token module due to PHP7.4 compatbility.", + "Explicit minimum version requirement of behat library due to PHP compatibility.", + "Explicit minimum version requirement for symfony/dom-crawler due to its lower versions using the deprecated function libxml_disable_entity_loader() in PHP8." + ], "scripts": { "post-install-cmd": "./vendor/bin/run drupal:site-setup", "post-update-cmd": "./vendor/bin/run drupal:site-setup" }, "repositories": { + "entity_version": { + "type": "vcs", + "url": "https://github.com/openeuropa/entity_version" + }, "drupal": { "type": "composer", "url": "https://packages.drupal.org/8" @@ -74,6 +92,13 @@ } }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "composer/installers": true, + "drupal/core-composer-scaffold": true, + "cweagans/composer-patches": true, + "dealerdirect/phpcodesniffer-composer-installer": true, + "phpro/grumphp": true + } } } diff --git a/docker-compose.yml b/docker-compose.yml index 3eb31ad..5ee8b87 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '2' services: web: - image: fpfis/httpd-php-dev:7.3 + image: fpfis/httpd-php-dev:8.0 working_dir: /var/www/html ports: - 8080:8080 @@ -10,6 +10,7 @@ services: - .:/var/www/html # Non Mac users. # - nfsmount:/var/www/html # Mac Users with the nfsmount volume. environment: + COMPOSERVER: "--2" XDEBUG_CONFIG: "client_host=172.17.0.1" # Non-Mac users. # XDEBUG_CONFIG: "client_host=host.docker.internal" # Mac users. XDEBUG_MODE: "develop, debug" diff --git a/grumphp.yml.dist b/grumphp.yml.dist index 2ddde30..700e81f 100644 --- a/grumphp.yml.dist +++ b/grumphp.yml.dist @@ -1,5 +1,10 @@ imports: - { resource: vendor/openeuropa/code-review/dist/drupal-conventions.yml } +grumphp: + extensions: + - OpenEuropa\CodeReview\ExtraTasksExtension + git_hook_variables: + EXEC_GRUMPHP_COMMAND: 'docker-compose exec -T web' parameters: tasks.phpcs.ignore_patterns: - vendor/ @@ -14,9 +19,15 @@ parameters: extra_tasks: phpparser: - ignore_patterns: "%tasks.phpcs.ignore_patterns%" + ignore_patterns: + - vendor/ + - node_modules/ + - build/ visitors: declare_strict_types: ~ - triggered_by: "%tasks.phpcs.triggered_by%" - extensions: - - OpenEuropa\CodeReview\ExtraTasksExtension + triggered_by: + - php + - module + - inc + - theme + - install diff --git a/modules/oe_editorial_content_lock/oe_editorial_content_lock.info.yml b/modules/oe_editorial_content_lock/oe_editorial_content_lock.info.yml index fd28832..af0bac1 100755 --- a/modules/oe_editorial_content_lock/oe_editorial_content_lock.info.yml +++ b/modules/oe_editorial_content_lock/oe_editorial_content_lock.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Editorial Content Lock description: Lock content to prevent concurrent editing. package: OpenEuropa type: module -core_version_requirement: ^8.9 || ^9.1 +core_version_requirement: ^9.2 dependencies: - content_lock:content_lock diff --git a/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/modules/oe_editorial_corporate_workflow_translation_poetry/oe_editorial_corporate_workflow_translation_poetry.info.yml b/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/modules/oe_editorial_corporate_workflow_translation_poetry/oe_editorial_corporate_workflow_translation_poetry.info.yml index 4120c3d..851acce 100644 --- a/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/modules/oe_editorial_corporate_workflow_translation_poetry/oe_editorial_corporate_workflow_translation_poetry.info.yml +++ b/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/modules/oe_editorial_corporate_workflow_translation_poetry/oe_editorial_corporate_workflow_translation_poetry.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Editorial Corporate Workflow Translation Poetry description: Integrates the editorial workflow with OE Translation Poetry package: OpenEuropa type: module -core_version_requirement: ^8.9 || ^9.1 +core_version_requirement: ^9.2 dependencies: - oe_editorial_corporate_workflow_translation:oe_editorial_corporate_workflow_translation diff --git a/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/oe_editorial_corporate_workflow_translation.info.yml b/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/oe_editorial_corporate_workflow_translation.info.yml index acae3a4..b40f48e 100644 --- a/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/oe_editorial_corporate_workflow_translation.info.yml +++ b/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/oe_editorial_corporate_workflow_translation.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Editorial Corporate Workflow Translation description: Integrates the editorial workflow with OE Translation package: OpenEuropa type: module -core_version_requirement: ^8.9 || ^9.1 +core_version_requirement: ^9.2 dependencies: - oe_editorial_corporate_workflow:oe_editorial_corporate_workflow diff --git a/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/modules/oe_editorial_corporate_workflow_translation_test/oe_editorial_corporate_workflow_translation_test.info.yml b/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/modules/oe_editorial_corporate_workflow_translation_test/oe_editorial_corporate_workflow_translation_test.info.yml index c840ad7..ea5c4c9 100644 --- a/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/modules/oe_editorial_corporate_workflow_translation_test/oe_editorial_corporate_workflow_translation_test.info.yml +++ b/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/modules/oe_editorial_corporate_workflow_translation_test/oe_editorial_corporate_workflow_translation_test.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Editorial Corporate Workflow Translation Test description: Test module for the OpenEuropa Editorial Corporate Workflow Translation package: Testing type: module -core_version_requirement: ^8.9 || ^9.1 +core_version_requirement: ^9.2 dependencies: - oe_editorial_workflow_demo:oe_editorial_workflow_demo diff --git a/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/Functional/CorporateWorkflowTranslationRevisionTest.php b/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/src/Functional/CorporateWorkflowTranslationRevisionTest.php similarity index 100% rename from modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/Functional/CorporateWorkflowTranslationRevisionTest.php rename to modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/src/Functional/CorporateWorkflowTranslationRevisionTest.php diff --git a/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/FunctionalJavascript/CorporateWorkflowTranslationDropTest.php b/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/src/FunctionalJavascript/CorporateWorkflowTranslationDropTest.php similarity index 100% rename from modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/FunctionalJavascript/CorporateWorkflowTranslationDropTest.php rename to modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/src/FunctionalJavascript/CorporateWorkflowTranslationDropTest.php diff --git a/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/Kernel/CorporateWorkflowTranslationTest.php b/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/src/Kernel/CorporateWorkflowTranslationTest.php similarity index 100% rename from modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/Kernel/CorporateWorkflowTranslationTest.php rename to modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/src/Kernel/CorporateWorkflowTranslationTest.php diff --git a/modules/oe_editorial_corporate_workflow/oe_editorial_corporate_workflow.info.yml b/modules/oe_editorial_corporate_workflow/oe_editorial_corporate_workflow.info.yml index e800cf9..fe6541b 100755 --- a/modules/oe_editorial_corporate_workflow/oe_editorial_corporate_workflow.info.yml +++ b/modules/oe_editorial_corporate_workflow/oe_editorial_corporate_workflow.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Editorial Corporate Workflow description: Editorial corporate workflow feature for the OpenEuropa project. package: OpenEuropa type: module -core_version_requirement: ^8.9 || ^9.1 +core_version_requirement: ^9.2 dependencies: - content_moderation:content_moderation diff --git a/modules/oe_editorial_corporate_workflow/tests/src/Traits/CorporateWorkflowTrait.php b/modules/oe_editorial_corporate_workflow/tests/src/Traits/CorporateWorkflowTrait.php index 513440e..e9a262c 100644 --- a/modules/oe_editorial_corporate_workflow/tests/src/Traits/CorporateWorkflowTrait.php +++ b/modules/oe_editorial_corporate_workflow/tests/src/Traits/CorporateWorkflowTrait.php @@ -19,7 +19,7 @@ trait CorporateWorkflowTrait { * The entity type manager. */ protected function getEntityTypeManager(): EntityTypeManagerInterface { - return isset($this->entityTypeManager) ? $this->entityTypeManager : \Drupal::entityTypeManager(); + return $this->entityTypeManager ?? \Drupal::entityTypeManager(); } /** @@ -49,7 +49,7 @@ protected function moderateNode(NodeInterface $node, string $target_state): Node $pos = array_search($current_state, $states); foreach (array_slice($states, $pos + 1) as $new_state) { - $node = isset($revision) ? $revision : $node; + $node = $revision ?? $node; $revision = $this->getEntityTypeManager()->getStorage('node')->createRevision($node); $revision->set('moderation_state', $new_state); $revision->save(); @@ -58,7 +58,7 @@ protected function moderateNode(NodeInterface $node, string $target_state): Node } } - return isset($revision) ? $revision : $node; + return $revision ?? $node; } } diff --git a/modules/oe_editorial_entity_version/oe_editorial_entity_version.info.yml b/modules/oe_editorial_entity_version/oe_editorial_entity_version.info.yml index 8391404..c7f1581 100755 --- a/modules/oe_editorial_entity_version/oe_editorial_entity_version.info.yml +++ b/modules/oe_editorial_entity_version/oe_editorial_entity_version.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Editorial Entity Version description: Editorial entity version brings the entity_version module configured for workflows. package: OpenEuropa type: module -core_version_requirement: ^8.9 || ^9.1 +core_version_requirement: ^9.2 dependencies: - entity_version_workflows:entity_version_workflows diff --git a/modules/oe_editorial_entity_version/oe_editorial_entity_version.install b/modules/oe_editorial_entity_version/oe_editorial_entity_version.install index 0526dfc..ebfbfa2 100644 --- a/modules/oe_editorial_entity_version/oe_editorial_entity_version.install +++ b/modules/oe_editorial_entity_version/oe_editorial_entity_version.install @@ -59,7 +59,7 @@ function oe_editorial_entity_version_install($is_syncing): void { } // Get the bundles the workflow is associated with. - $bundles = isset($corporate_workflow->get('type_settings')['entity_types']['node']) ? $corporate_workflow->get('type_settings')['entity_types']['node'] : []; + $bundles = $corporate_workflow->get('type_settings')['entity_types']['node'] ?? []; if (!$bundles) { return; } diff --git a/modules/oe_editorial_unpublish/oe_editorial_unpublish.info.yml b/modules/oe_editorial_unpublish/oe_editorial_unpublish.info.yml index 39b50f7..4bde52f 100644 --- a/modules/oe_editorial_unpublish/oe_editorial_unpublish.info.yml +++ b/modules/oe_editorial_unpublish/oe_editorial_unpublish.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Editorial Unpublish description: Adds an "Unpublish" action tab with a confirmation page for moderated content. package: OpenEuropa type: module -core_version_requirement: ^8.9 || ^9.1 +core_version_requirement: ^9.2 dependencies: - content_moderation:content_moderation diff --git a/modules/oe_editorial_unpublish/src/Form/ContentEntityUnpublishForm.php b/modules/oe_editorial_unpublish/src/Form/ContentEntityUnpublishForm.php index 1b38c4a..f943b61 100644 --- a/modules/oe_editorial_unpublish/src/Form/ContentEntityUnpublishForm.php +++ b/modules/oe_editorial_unpublish/src/Form/ContentEntityUnpublishForm.php @@ -216,7 +216,7 @@ public function submitForm(array &$form, FormStateInterface $form_state): void { */ public function access(AccountInterface $account, RouteMatchInterface $routeMatch): AccessResultInterface { $entity_form = $routeMatch->getRouteObject()->getDefault('_entity_form'); - list($entity_type_id, $operation) = explode('.', $entity_form); + [$entity_type_id, $operation] = explode('.', $entity_form); $entity = $this->getEntityFromRouteMatch($routeMatch, $entity_type_id); $cache = new CacheableMetadata(); $cache->addCacheContexts(['url']); diff --git a/modules/oe_editorial_unpublish/tests/modules/oe_editorial_unpublish_test/oe_editorial_unpublish_test.info.yml b/modules/oe_editorial_unpublish/tests/modules/oe_editorial_unpublish_test/oe_editorial_unpublish_test.info.yml index 0d6b428..8e763ec 100644 --- a/modules/oe_editorial_unpublish/tests/modules/oe_editorial_unpublish_test/oe_editorial_unpublish_test.info.yml +++ b/modules/oe_editorial_unpublish/tests/modules/oe_editorial_unpublish_test/oe_editorial_unpublish_test.info.yml @@ -2,7 +2,7 @@ name: 'OpenEuropa Editorial Unpublish Test' type: module description: 'Helper module to test the Editorial Unpublish module.' package: Testing -core_version_requirement: ^8.9 || ^9.1 +core_version_requirement: ^9.2 dependencies: - oe_editorial_unpublish:oe_editorial_unpublish diff --git a/modules/oe_editorial_workflow_demo/oe_editorial_workflow_demo.info.yml b/modules/oe_editorial_workflow_demo/oe_editorial_workflow_demo.info.yml index a8b2889..9afc235 100755 --- a/modules/oe_editorial_workflow_demo/oe_editorial_workflow_demo.info.yml +++ b/modules/oe_editorial_workflow_demo/oe_editorial_workflow_demo.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Editorial Workflow Demo description: Editorial workflow demo module to showcase the workflows for the OpenEuropa project. package: OpenEuropa type: module -core_version_requirement: ^8.9 || ^9.1 +core_version_requirement: ^9.2 dependencies: - oe_editorial_entity_version:oe_editorial_entity_version diff --git a/modules/oe_editorial_workflow_demo/oe_editorial_workflow_demo.install b/modules/oe_editorial_workflow_demo/oe_editorial_workflow_demo.install index ef7b89b..188804c 100755 --- a/modules/oe_editorial_workflow_demo/oe_editorial_workflow_demo.install +++ b/modules/oe_editorial_workflow_demo/oe_editorial_workflow_demo.install @@ -21,7 +21,7 @@ function oe_editorial_workflow_demo_install($is_syncing): void { // Add entity version field to corporate workflow bundles. /** @var \Drupal\workflows\WorkflowInterface $corporate_workflow */ $corporate_workflow = \Drupal::entityTypeManager()->getStorage('workflow')->load('oe_corporate_workflow'); - $bundles = isset($corporate_workflow->get('type_settings')['entity_types']['node']) ? $corporate_workflow->get('type_settings')['entity_types']['node'] : []; + $bundles = $corporate_workflow->get('type_settings')['entity_types']['node'] ?? []; if (!$bundles) { return; } diff --git a/oe_editorial.info.yml b/oe_editorial.info.yml index a25a19b..b2fe35b 100644 --- a/oe_editorial.info.yml +++ b/oe_editorial.info.yml @@ -2,4 +2,4 @@ name: OpenEuropa Editorial description: Editorial features for the OpenEuropa project. package: OpenEuropa type: module -core_version_requirement: ^8.9 || ^9.1 +core_version_requirement: ^9.2 From f20ea34fb5b35c5ae24b8d75bb227cbe7e8a2623 Mon Sep 17 00:00:00 2001 From: nagyad Date: Fri, 4 Feb 2022 12:02:25 +0100 Subject: [PATCH 2/4] EWPP-1912: Revision revert form gets the node revision loaded already. --- .../src/Form/NodeRevisionRevertForm.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/oe_editorial_entity_version/src/Form/NodeRevisionRevertForm.php b/modules/oe_editorial_entity_version/src/Form/NodeRevisionRevertForm.php index fed19e0..a59e2fb 100644 --- a/modules/oe_editorial_entity_version/src/Form/NodeRevisionRevertForm.php +++ b/modules/oe_editorial_entity_version/src/Form/NodeRevisionRevertForm.php @@ -12,6 +12,7 @@ use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; +use Drupal\node\NodeInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -127,7 +128,13 @@ public function getConfirmText() { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state, $node_revision = NULL) { - $this->revision = $this->entityTypeManager->getStorage('node')->loadRevision($node_revision); + // We need to anticipate string or NodeInterface types of $node_revision to + // be compatible with both core versions v9.2 and v9.3. + // @see: https://www.drupal.org/project/drupal/issues/2730631 + $this->revision = $node_revision; + if (!$this->revision instanceof NodeInterface) { + $this->revision = $this->entityTypeManager->getStorage('node')->loadRevision($node_revision); + } $this->versionField = $this->getVersionField($this->revision); $form = parent::buildForm($form, $form_state); From 0c194a99f577c21668bc5e9d420662ab0026bd89 Mon Sep 17 00:00:00 2001 From: nagyad Date: Fri, 4 Feb 2022 14:42:18 +0100 Subject: [PATCH 3/4] EWPP-1912: Use workflow api for workflow installations. --- .drone.yml | 2 - composer.json | 18 ++++---- .../CorporateWorkflowTranslationTest.php | 8 ++-- ..._editorial_corporate_workflow.services.yml | 2 +- .../src/CorporateWorkflowInstaller.php | 44 +++++-------------- 5 files changed, 24 insertions(+), 50 deletions(-) diff --git a/.drone.yml b/.drone.yml index 7e6a406..957953f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -60,8 +60,6 @@ pipeline: volumes: - /cache/${DRONE_REPO_NAME}:/cache commands: - # @todo remove "composer install" step once the following issue is fixed. - # @link https://webgate.ec.europa.eu/CITnet/jira/browse/OPENEUROPA-1234 - composer update --prefer-lowest --prefer-stable --ansi --no-progress --no-interaction when: matrix: diff --git a/composer.json b/composer.json index 857464b..b76a225 100644 --- a/composer.json +++ b/composer.json @@ -36,14 +36,6 @@ "phpspec/prophecy-phpunit": "^2", "symfony/dom-crawler": "^4.4.12" }, - "_readme": [ - "Explicit requirement for private repository of entity_version contrib module until next release.", - "Explicit minimum version requirement of drupal/ctools module due to D9.2 compatability.", - "Explicit requirement for egulias/email-validator due to https://www.drupal.org/project/drupal/issues/3061074#comment-14300579. It can be removed when Drupal core 9.2 support is droppped.", - "Explicit requirement of drupal/token module due to PHP7.4 compatbility.", - "Explicit minimum version requirement of behat library due to PHP compatibility.", - "Explicit minimum version requirement for symfony/dom-crawler due to its lower versions using the deprecated function libxml_disable_entity_loader() in PHP8." - ], "scripts": { "post-install-cmd": "./vendor/bin/run drupal:site-setup", "post-update-cmd": "./vendor/bin/run drupal:site-setup" @@ -89,7 +81,15 @@ "locations": { "web-root": "./build" } - } + }, + "_readme": [ + "Explicit requirement for private repository of entity_version contrib module until next release.", + "Explicit minimum version requirement of drupal/ctools module due to D9.2 compatability.", + "Explicit requirement for egulias/email-validator due to https://www.drupal.org/project/drupal/issues/3061074#comment-14300579. It can be removed when Drupal core 9.2 support is droppped.", + "Explicit requirement of drupal/token module due to PHP7.4 compatbility.", + "Explicit minimum version requirement of behat library due to PHP compatibility.", + "Explicit minimum version requirement for symfony/dom-crawler due to its lower versions using the deprecated function libxml_disable_entity_loader() in PHP8." + ] }, "config": { "sort-packages": true, diff --git a/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/src/Kernel/CorporateWorkflowTranslationTest.php b/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/src/Kernel/CorporateWorkflowTranslationTest.php index 0242e51..0c01286 100644 --- a/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/src/Kernel/CorporateWorkflowTranslationTest.php +++ b/modules/oe_editorial_corporate_workflow/modules/oe_editorial_corporate_workflow_translation/tests/src/Kernel/CorporateWorkflowTranslationTest.php @@ -7,6 +7,7 @@ use Drupal\KernelTests\KernelTestBase; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\node\Entity\NodeType; +use Drupal\workflows\Entity\Workflow; /** * Testing custom translation-related logic. @@ -64,10 +65,9 @@ protected function setUp() { $this->container->get('oe_editorial_corporate_workflow.workflow_installer')->installWorkflow($node_type->id()); // Add the workflow to the test entity as well. - $config = $this->config('workflows.workflow.oe_corporate_workflow'); - $config_value = $config->get('type_settings.entity_types.entity_test_mulrev'); - $config_value[] = 'entity_test_mulrev'; - $config->set('type_settings.entity_types.entity_test_mulrev', $config_value)->save(); + $workflow = Workflow::load('oe_corporate_workflow'); + $workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_mulrev', 'entity_test_mulrev'); + $workflow->save(); ConfigurableLanguage::create(['id' => 'fr'])->save(); } diff --git a/modules/oe_editorial_corporate_workflow/oe_editorial_corporate_workflow.services.yml b/modules/oe_editorial_corporate_workflow/oe_editorial_corporate_workflow.services.yml index 7a391c2..542d03b 100644 --- a/modules/oe_editorial_corporate_workflow/oe_editorial_corporate_workflow.services.yml +++ b/modules/oe_editorial_corporate_workflow/oe_editorial_corporate_workflow.services.yml @@ -1,7 +1,7 @@ services: oe_editorial_corporate_workflow.workflow_installer: class: Drupal\oe_editorial_corporate_workflow\CorporateWorkflowInstaller - arguments: ['@config.factory', '@entity_type.manager'] + arguments: ['@entity_type.manager'] oe_editorial_corporate_workflow.shortcut_transition_handler: class: Drupal\oe_editorial_corporate_workflow\Services\ShortcutRevisionHandler arguments: ['@content_moderation.moderation_information', '@current_user', '@entity_type.manager', '@datetime.time'] diff --git a/modules/oe_editorial_corporate_workflow/src/CorporateWorkflowInstaller.php b/modules/oe_editorial_corporate_workflow/src/CorporateWorkflowInstaller.php index deff6f7..a77a03b 100644 --- a/modules/oe_editorial_corporate_workflow/src/CorporateWorkflowInstaller.php +++ b/modules/oe_editorial_corporate_workflow/src/CorporateWorkflowInstaller.php @@ -4,7 +4,6 @@ namespace Drupal\oe_editorial_corporate_workflow; -use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\user\RoleInterface; @@ -14,11 +13,11 @@ class CorporateWorkflowInstaller { /** - * The config factory. + * The corporate editorial workflow. * - * @var \Drupal\Core\Config\ConfigFactoryInterface + * @var \Drupal\workflows\WorkflowInterface */ - protected $configFactory; + protected $workflow; /** * The entity type manager. @@ -30,14 +29,12 @@ class CorporateWorkflowInstaller { /** * CorporateWorkflowInstaller constructor. * - * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory - * The config factory. * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager * The entity type manager. */ - public function __construct(ConfigFactoryInterface $configFactory, EntityTypeManagerInterface $entityTypeManager) { - $this->configFactory = $configFactory; + public function __construct(EntityTypeManagerInterface $entityTypeManager) { $this->entityTypeManager = $entityTypeManager; + $this->workflow = $this->entityTypeManager->getStorage('workflow')->load('oe_corporate_workflow'); } /** @@ -47,10 +44,8 @@ public function __construct(ConfigFactoryInterface $configFactory, EntityTypeMan * The content type to enable the workflow on. */ public function installWorkflow(string $content_type): void { - $config = $this->configFactory->getEditable('workflows.workflow.oe_corporate_workflow'); - $config_value = $config->get('type_settings.entity_types.node'); - $config_value[] = $content_type; - $config->set('type_settings.entity_types.node', $config_value)->save(); + $this->workflow->getTypePlugin()->addEntityTypeAndBundle('node', $content_type); + $this->workflow->save(); $this->handlePermissions('grant', $content_type); } @@ -61,29 +56,10 @@ public function installWorkflow(string $content_type): void { * The content type to uninstall the workflow from. */ public function uninstallWorkflow(string $content_type): void { - $config = $this->configFactory->getEditable('workflows.workflow.oe_corporate_workflow'); - $config_values = $config->get('type_settings.entity_types.node'); - if (!$config_values) { - $this->handlePermissions('revoke', $content_type); - return; + if ($this->workflow->getTypePlugin()->appliesToEntityTypeAndBundle('node', $content_type)) { + $this->workflow->getTypePlugin()->removeEntityTypeAndBundle('node', $content_type); + $this->workflow->save(); } - - $search = array_search($content_type, $config_values); - if ($search === FALSE) { - $this->handlePermissions('revoke', $content_type); - return; - } - - unset($config_values[$search]); - - if (empty($config_values)) { - // We save without any entity types on the workflow. - $config->set('type_settings.entity_types', [])->save(); - $this->handlePermissions('revoke', $content_type); - return; - } - - $config->set('type_settings.entity_types.node', $config_values)->save(); $this->handlePermissions('revoke', $content_type); } From e57f97996228c39240a23a94aae8161b2b9cbcf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hern=C3=A2ni=20Borges=20de=20Freitas?= Date: Mon, 7 Feb 2022 16:46:59 +0000 Subject: [PATCH 4/4] EWPP-1912: Adapt composer depdendencies. --- composer.json | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index b76a225..e20ee68 100644 --- a/composer.json +++ b/composer.json @@ -20,10 +20,10 @@ "drupal/core-dev": "^9.2", "drupal/ctools": "^3.7", "drupal/drupal-extension": "^4.0", - "drupal/entity_version": "dev-EWPP-1912", + "drupal/entity_version": "^1.0-beta8", "drupal/token": "^1.10", "drush/drush": "^10.3", - "ec-europa/oe-poetry-client": "dev-master", + "ec-europa/oe-poetry-client": "^0.6", "egulias/email-validator": "^2.1.22 || ^3.0", "instaclick/php-webdriver": "^1.4.7", "nikic/php-parser": "^4.12.0", @@ -31,7 +31,7 @@ "openeuropa/code-review": "^2.0", "openeuropa/oe_multilingual": "^1.10", "openeuropa/oe_paragraphs": "^1.10", - "openeuropa/oe_translation": "dev-EWPP-1908", + "openeuropa/oe_translation": "^0.17", "openeuropa/task-runner-drupal-project-symlink": "^1.0-beta5", "phpspec/prophecy-phpunit": "^2", "symfony/dom-crawler": "^4.4.12" @@ -41,10 +41,6 @@ "post-update-cmd": "./vendor/bin/run drupal:site-setup" }, "repositories": { - "entity_version": { - "type": "vcs", - "url": "https://github.com/openeuropa/entity_version" - }, "drupal": { "type": "composer", "url": "https://packages.drupal.org/8" @@ -83,7 +79,6 @@ } }, "_readme": [ - "Explicit requirement for private repository of entity_version contrib module until next release.", "Explicit minimum version requirement of drupal/ctools module due to D9.2 compatability.", "Explicit requirement for egulias/email-validator due to https://www.drupal.org/project/drupal/issues/3061074#comment-14300579. It can be removed when Drupal core 9.2 support is droppped.", "Explicit requirement of drupal/token module due to PHP7.4 compatbility.",