Skip to content

Commit

Permalink
Merge pull request #51 from openeuropa/EWPP-3968
Browse files Browse the repository at this point in the history
EWPP-3968: Add Drupal 10.2.x and PHP 8.2 to matrix.
  • Loading branch information
nagyad authored Feb 14, 2024
2 parents 984b29b + 266ed1e commit 671b7f7
Show file tree
Hide file tree
Showing 56 changed files with 125 additions and 142 deletions.
24 changes: 7 additions & 17 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,16 @@ services:
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
selenium:
image: registry.fpfis.eu/fpfis/selenium:standalone-chrome-3.141.59-oxygen
image: registry.fpfis.eu/fpfis/selenium:standalone-chrome-4.1.3-20220405
shm_size: 2g
environment:
- DISPLAY=:99
- SE_OPTS=-debug
- SCREEN_WIDTH=1280
- SCREEN_HEIGHT=800
- NODE_MAX_INSTANCES=5
- NODE_MAX_SESSION=5

pipeline:
composer-drop-patch:
group: warmup
image: registry.fpfis.eu/fpfis/httpd-php:${PHP_VERSION}-ci
volumes:
- /cache:/cache
commands:
# Drop Drupal patch that is needed only for 9.x.
- composer config --unset --json "extra.patches.drupal/core"
when:
matrix:
CORE_VERSION: "10.0"
composer-install:
group: prepare
image: registry.fpfis.eu/fpfis/httpd-php:${PHP_VERSION}-ci
Expand Down Expand Up @@ -82,9 +70,11 @@ pipeline:

matrix:
include:
- CORE_VERSION: 9.5.0
PHP_VERSION: 8.0
- CORE_VERSION: 9.5.0
- CORE_VERSION: 10.1.0
PHP_VERSION: 8.1
- CORE_VERSION: 10.0
- CORE_VERSION: 10.1.0
PHP_VERSION: 8.2
- CORE_VERSION: 10.2.0
PHP_VERSION: 8.1
- CORE_VERSION: 10.2.0
PHP_VERSION: 8.2
25 changes: 0 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,6 @@ It does that by providing:

Once a content type is equipped with an open vocabulary field, users with appropriate access can decide which type of entities that field will able to reference, by creating associations.

# Requirements

This module unfortunately requires a patch to Drupal core 9.x releases, due to a bug that prevents placing the generated fields
programmatically in the form display.\
The patch is already included in this component composer.json. To have it installed, first require the component needed to apply the patch:
```bash
composer require cweagans/composer-patches
```
Then add in the `extra` section of your project `composer.json`:
```json
[...]
"extra": {
"composer-exit-on-patch-failure": true,
"enable-patching": true,
[...]
}
[...]
```

If you require this module in Drupal 10 you must set said patch as ignored in your composer.json.\
You can do this with the following command:
```bash
composer config --merge --json "extra.patches-ignore.openeuropa/open_vocabularies" '{"drupal/core": {"Entity display entities are incorrectly unserialized @see https://www.drupal.org/project/drupal/issues/3171333": "https://www.drupal.org/files/issues/2020-09-17/3171333-6.patch"}}'
```

## Development setup

You can build the development site by running the following steps:
Expand Down
19 changes: 7 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.0",
"cweagans/composer-patches": "~1.4",
"drupal/core": "^9.4 || ^10"
"php": ">=8.1",
"drupal/core": "^10"
},
"require-dev": {
"composer/installers": "^1.11",
"drupal/core-composer-scaffold": "^9.4 || ^10",
"drupal/core-dev": "^9.4 || ^10",
"drush/drush": "^11.1",
"drupal/core-composer-scaffold": "^10",
"drupal/core-dev": "^10",
"drush/drush": "^12",
"drupal/field_group": "^3.2",
"openeuropa/code-review": "^2.0.0-alpha6",
"openeuropa/task-runner-drupal-project-symlink": "^1.0.0-beta6",
Expand Down Expand Up @@ -50,11 +49,6 @@
"build/modules/contrib/{$name}": ["type:drupal-module"],
"build/themes/contrib/{$name}": ["type:drupal-theme"]
},
"patches": {
"drupal/core": {
"Entity display entities are incorrectly unserialized @see https://www.drupal.org/project/drupal/issues/3171333": "https://www.drupal.org/files/issues/2020-09-17/3171333-6.patch"
}
},
"drupal-scaffold": {
"locations": {
"web-root": "./build"
Expand All @@ -69,7 +63,8 @@
"dealerdirect/phpcodesniffer-composer-installer": true,
"drupal/core-composer-scaffold": true,
"phpro/grumphp": true,
"phpstan/extension-installer": true
"phpstan/extension-installer": true,
"php-http/discovery": false
}
}
}
13 changes: 3 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,16 @@ services:
# ports:
# - 3306:3306

# If you would like to see what is going on you can run the following on your host:
# docker run --rm -p 4444:4444 -p 5900:5900 --network="host" selenium/standalone-chrome-debug:latest
# Newer version of this image might run into this issue:
# @link https://github.com/elgalu/docker-selenium/issues/20
# Visit localhost:7900 to access the browser.
selenium:
image: selenium/standalone-chrome-debug:3.141.59-oxygen
expose:
- '4444'
image: selenium/standalone-chrome:4.1.3-20220405
environment:
- DISPLAY=:99
- SE_OPTS=-debug
- SCREEN_WIDTH=1280
- SCREEN_HEIGHT=800
- VNC_NO_PASSWORD=1
ports:
- '4444:4444'
- '5900:5900'
- '7900:7900'
shm_size: 2g

#### Mac users: uncomment the "volumes" key to enable the NFS file sharing. You can find more information about Docker for Mac here: https://github.com/openeuropa/openeuropa/blob/master/docs/starting/tooling.md#using-docker-on-macos
Expand Down
2 changes: 1 addition & 1 deletion open_vocabularies.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ description: Choose how a piece of content will be categorised without having to
package: OpenEuropa

type: module
core_version_requirement: ^9.4 || ^10
core_version_requirement: ^10
2 changes: 1 addition & 1 deletion open_vocabularies.module
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Hook implementations for the Open vocabularies module.
*/

declare(strict_types = 1);
declare(strict_types=1);

use Drupal\Core\Entity\ContentEntityFormInterface;
use Drupal\Core\Entity\Display\EntityFormDisplayInterface;
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<env name="SIMPLETEST_IGNORE_DIRECTORIES" value="${drupal.root}"/>
<env name="SIMPLETEST_BASE_URL" value="${drupal.base_url}"/>
<env name="SIMPLETEST_DB" value="mysql://${drupal.database.user}:${drupal.database.password}@${drupal.database.host}:${drupal.database.port}/${drupal.database.name}"/>
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value='["${selenium.browser}", null, "${selenium.host}:${selenium.port}/wd/hub"]'/>
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value='["${selenium.browser}", {"browserName":"chrome","chromeOptions":{"w3c": false, "args":["--no-sandbox", "--start-maximized", "--disable-gpu", "--window-size=1440,900", "--disable-dev-shm-usage", "--disable-setuid-sandbox", "--disable-web-security", "--DNS-prefetch-disable", "--disable-translate", "--ignore-certificate-errors", "--test-type", "--disable-extensions", "--incognito", "--disable-infobars"]}}, "${selenium.host}:${selenium.port}/wd/hub"]'/>
</php>
<testsuites>
<testsuite name="Open Vocabularies Tests">
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/OpenVocabulary.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\open_vocabularies\Entity;

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/OpenVocabularyAssociation.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\open_vocabularies\Entity;

Expand Down
2 changes: 1 addition & 1 deletion src/Form/OpenVocabularyAssociationForm.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\open_vocabularies\Form;

Expand Down
2 changes: 1 addition & 1 deletion src/Form/OpenVocabularyDeleteForm.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\open_vocabularies\Form;

Expand Down
50 changes: 47 additions & 3 deletions src/Form/OpenVocabularyForm.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\open_vocabularies\Form;

use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Render\Element;
use Drupal\open_vocabularies\Entity\OpenVocabulary;
use Drupal\open_vocabularies\VocabularyReferenceHandlerPluginManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
Expand Down Expand Up @@ -103,7 +103,7 @@ public function form(array $form, FormStateInterface $form_state) {
'#tree' => TRUE,
'#type' => 'container',
'#id' => 'vocabulary-handler-settings-wrapper',
'#process' => [[EntityReferenceItem::class, 'fieldSettingsAjaxProcess']],
'#process' => [[static::class, 'fieldSettingsAjaxProcess']],
'#element_validate' => ['::validateSelectionPluginHandlerConfiguration'],
// The selection handlers expect the form elements to be under a specific
// array key.
Expand Down Expand Up @@ -221,6 +221,50 @@ public function validateSelectionPluginHandlerConfiguration(array $form, FormSta
$vocabulary_handler->getHandler()->validateConfigurationForm($form, $form_state);
}

/**
* Ajax callback for the handler settings form.
*
* Copied from \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::settingsAjax()
* version 10.1. In 10.2 the callback was reworked and doesn't apply anymore
* to our form.
*/
public static function settingsAjax($form, FormStateInterface $form_state) {
return NestedArray::getValue($form, $form_state->getTriggeringElement()['#ajax']['element']);
}

/**
* Render API callback: Processes the field settings form.
*
* Copied from \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::fieldSettingsAjaxProcess()
* version 10.1. In 10.2 the callback was reworked and doesn't apply anymore
* to our form.
*/
public static function fieldSettingsAjaxProcess($form, FormStateInterface $form_state) {
static::fieldSettingsAjaxProcessElement($form, $form);
return $form;
}

/**
* Adds the field settings to AJAX form elements.
*
* Copied from \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::fieldSettingsAjaxProcessElement()
* version 10.1. In 10.2 the callback was reworked and doesn't apply anymore
* to our form.
*/
public static function fieldSettingsAjaxProcessElement(&$element, $main_form) {
if (!empty($element['#ajax'])) {
$element['#ajax'] = [
'callback' => [static::class, 'settingsAjax'],
'wrapper' => $main_form['#id'],
'element' => $main_form['#array_parents'],
];
}

foreach (Element::children($element) as $key) {
static::fieldSettingsAjaxProcessElement($element[$key], $main_form);
}
}

/**
* Returns if any association entities are targeting the current vocabulary.
*
Expand Down
2 changes: 1 addition & 1 deletion src/OpenVocabularyAssociationInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\open_vocabularies;

Expand Down
2 changes: 1 addition & 1 deletion src/OpenVocabularyAssociationListBuilder.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\open_vocabularies;

Expand Down
2 changes: 1 addition & 1 deletion src/OpenVocabularyAssociationStorage.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\open_vocabularies;

Expand Down
2 changes: 1 addition & 1 deletion src/OpenVocabularyAssociationStorageInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\open_vocabularies;

Expand Down
2 changes: 1 addition & 1 deletion src/OpenVocabularyInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\open_vocabularies;

Expand Down
2 changes: 1 addition & 1 deletion src/OpenVocabularyListBuilder.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\open_vocabularies;

Expand Down
2 changes: 1 addition & 1 deletion src/OpenVocabularyStorage.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\open_vocabularies;

Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/DataType/VocabularyEntityReference.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\open_vocabularies\Plugin\DataType;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\open_vocabularies\Plugin\Field;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\open_vocabularies\Plugin\Field\FieldFormatter;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\open_vocabularies\Plugin\Field\FieldFormatter;

Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/Field/FieldType/VocabularyReferenceItem.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\open_vocabularies\Plugin\Field\FieldType;

Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/Field/FieldWidget/VocabularyReferenceWidget.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\open_vocabularies\Plugin\Field\FieldWidget;

Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/Field/VocabularyReferenceFieldItemList.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Drupal\open_vocabularies\Plugin\Field;

Expand Down
Loading

0 comments on commit 671b7f7

Please sign in to comment.