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

[ODSG-45] D10 upgrade #235

Merged
merged 16 commits into from
Aug 30, 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
4 changes: 0 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@ jobs:
with:
run: |
docker compose -f tests/docker-compose.yml exec -T drupal drush -y en dblog
docker compose -f tests/docker-compose.yml exec -T drupal drush -y cset system.site uuid $(grep uuid ./config/system.site.yml | awk '{print $2}')
docker compose -f tests/docker-compose.yml exec -T drupal drush -y cim --source=/srv/www/config
docker compose -f tests/docker-compose.yml exec -T drupal drush php-eval 'node_access_rebuild();'
docker compose -f tests/docker-compose.yml exec -T drupal drush cr
docker compose -f tests/docker-compose.yml exec -T drupal drush en yaml_content -y
docker compose -f tests/docker-compose.yml exec -T drupal drush yaml-content-import /srv/www/tests
docker compose -f tests/docker-compose.yml exec -T drupal chmod -R 777 /srv/www/html/sites/default/files /srv/www/html/sites/default/private
Expand Down
45 changes: 32 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
# Ignore directories generated by Composer
/drush/contrib/
/vendor/
/html/core/
/html/modules/contrib/
/html/themes/contrib/
/html/profiles/contrib/
/html/libraries/
/bin/
/.composer/

# Ignore drupal code except for the custom modules and themes.
/html/*

!/html/modules/
/html/modules/*
!/html/modules/custom/

!/html/themes/
/html/themes/*
!/html/themes/custom/

# Ignore sensitive information
/html/sites/*/settings.php
/html/sites/*/settings.local.php
/html/sites/*/services.yml

# Ignore local development files.
/local/.env
/local/shared/settings/settings.site.php

/vendor/
/bin/
# Ignore .env files as they are personal
/.env

# Ignore Drupal's file directory
/html/sites/*/files/
/html/sites/*/private/

# Ignore SimpleTest multi-site environment.
/html/sites/simpletest
Expand All @@ -36,14 +41,28 @@ buildlog.txt
/database/
/private/
/notes/
/.idea/

# Ignore local development files.
/local/.env
/local/shared/settings/settings.site.php

# Coverage
/phpcov.phar
/code-coverage-report-clover/
/coverage/
/html/sites/default/browser_output/

###> squizlabs/php_codesniffer ###
/.phpcs-cache
/tests/coverage/
###< squizlabs/php_codesniffer ###

###> phpunit/phpunit ###
/phpunit.xml
.phpunit.result.cache
###< phpunit/phpunit ###

###> symfony/phpunit-bridge ###
.phpunit
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###
27 changes: 17 additions & 10 deletions PATCHES/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
ODSG - Patches
==============
# Patches

Patches for the Drupal core, libraries, modules and themes.
Information about Drupal patches.

## Drupal 10 compatibility patches

Drupal core patches
-------------------
In order to apply the compatibility patches generated by Drupal rector for
example, the https://github.com/orakili/composer-drupal-info-file-patch-helper
needs to be added to the composer.json.

### Core - core/lib/Drupal/Component/Utility/Xss.php
### Add a new incompatible module

- `core--drupal--xss-prevent-protocol-stripping-on-datetime-attribute.patch`
1. Add an entry for the module in `extra.drupal-lenient.allowed-list` in the
composer.json file
2. Add the compatibility patch in the `composer.patches.json` file.
3. Require the module via `composer require drupal/module`

https://www.drupal.org/node/2544110
Prevent protocol stripping on the [datetime](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time)
attribute as it truncates dates like `2020-01-01T:00:00:00` to `00`...
## Core patches to review

Review the Drupal 10 compatibility of the following patches:

- [XSS Filter](https://www.drupal.org/project/drupal/issues/2544110)
- [Pager query parameter](https://www.drupal.org/project/drupal/issues/3143617)
17 changes: 17 additions & 0 deletions PATCHES/core-ckeditor5-dialog-fix-3351600.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/core/modules/ckeditor5/js/ckeditor5.dialog.fix.js b/core/modules/ckeditor5/js/ckeditor5.dialog.fix.js
index 1f4ed1d7feb523cffee35f245b7dab06da4f38fa..41449dcf693fab7ff15220fd4b57bd89a71cab8d 100644
--- a/core/modules/ckeditor5/js/ckeditor5.dialog.fix.js
+++ b/core/modules/ckeditor5/js/ckeditor5.dialog.fix.js
@@ -12,6 +12,12 @@
// CKEditor 5 in modals can work as expected.
// @see https://api.jqueryui.com/dialog/#method-_allowInteraction
_allowInteraction(event) {
+ // Fixes "Uncaught TypeError: event.target.classList is undefined"
+ // in Firefox (only).
+ // @see https://www.drupal.org/project/drupal/issues/3351600
+ if (event.target.classList === undefined) {
+ return this._super(event);
+ }
return event.target.classList.contains('ck') || this._super(event);
},
});
15 changes: 15 additions & 0 deletions PATCHES/core-css-js-aggregation-3376927.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/core/modules/system/src/Controller/AssetControllerBase.php b/core/modules/system/src/Controller/AssetControllerBase.php
index 620b2ecccf..cce4c397cc 100644
--- a/core/modules/system/src/Controller/AssetControllerBase.php
+++ b/core/modules/system/src/Controller/AssetControllerBase.php
@@ -191,10 +191,6 @@ public function deliver(Request $request, string $file_name) {
// referenced in cached HTML.
if (hash_equals($generated_hash, $received_hash)) {
$uri = $this->dumper->dumpToUri($data, $this->assetType, $uri);
- $state_key = 'drupal_' . $this->assetType . '_cache_files';
- $files = $this->state()->get($state_key, []);
- $files[] = $uri;
- $this->state()->set($state_key, $files);
}
return new Response($data, 200, [
'Cache-control' => static::CACHE_CONTROL,
25 changes: 25 additions & 0 deletions PATCHES/core-views-php-82-compatibility.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
diff --git a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php
index 1e0740fc9d..15f8d4fc9f 100644
--- a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php
+++ b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php
@@ -59,6 +59,20 @@ abstract class QueryPluginBase extends PluginBase implements CacheableDependency
*/
protected $groupOperator;

+ /**
+ * WHERE groups.
+ *
+ * @var array
+ */
+ protected $where;
+
+ /**
+ * HAVING groups.
+ *
+ * @var array
+ */
+ protected $having;
+
/**
* Generate a query and a countquery from all of the information supplied.
*
187 changes: 187 additions & 0 deletions PATCHES/maintenance200-drupal-10-compatibility.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
diff --git a/maintenance200.info.yml b/maintenance200.info.yml
index fa88b4e..9e81116 100755
--- a/maintenance200.info.yml
+++ b/maintenance200.info.yml
@@ -1,6 +1,5 @@
name: 'Maintenance 200'
type: module
description: 'Allows the maintenance page to return a configurable HTTP status code rather than the standard 503 code.'
-core: 8.x
-core_version_requirement: ^8 || ^9
+core_version_requirement: ^9.1 || ^10
configure: maintenance200_settings
diff --git a/src/EventSubscriber/MaintenanceModeSubscriber.php b/src/EventSubscriber/MaintenanceModeSubscriber.php
index 59c9691..21c58ab 100644
--- a/src/EventSubscriber/MaintenanceModeSubscriber.php
+++ b/src/EventSubscriber/MaintenanceModeSubscriber.php
@@ -2,21 +2,40 @@

namespace Drupal\maintenance200\EventSubscriber;

+use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
-use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
-use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
-use Symfony\Component\HttpKernel\Event\FilterResponseEvent;

use Drupal\Core\Site\MaintenanceModeInterface;
use Drupal\Core\Session\AccountInterface;
+use Drupal\Core\Config\ImmutableConfig;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Routing\RouteMatch;

-
class MaintenanceModeSubscriber implements EventSubscriberInterface {

+ /**
+ * Configuration.
+ *
+ * @var \Drupal\Core\Config\ImmutableConfig
+ */
+ private ImmutableConfig $config;
+
+ /**
+ * Maintenance mode.
+ *
+ * @var \Drupal\Core\Site\MaintenanceModeInterface
+ */
+ private MaintenanceModeInterface $maintenanceMode;
+
+ /**
+ * User account.
+ *
+ * @var \Drupal\Core\Session\AccountInterface
+ */
+ private AccountInterface $account;
+
/**
* @inheritDoc
*/
@@ -30,7 +49,7 @@ class MaintenanceModeSubscriber implements EventSubscriberInterface {
* Respond to RESPONSE Kernel event by setting status code if in maintenance.
*
*/
- public function onKernelResponse(FilterResponseEvent $event) {
+ public function onKernelResponse(ResponseEvent $event) {
if ($this->config->get('maintenance200_enabled')) {
$status_code = $this->config->get('maintenance200_status_code');
$request = $event->getRequest();
diff --git a/tests/src/Functional/Maintenance200SettingsTest.php b/tests/src/Functional/Maintenance200SettingsTest.php
index 044f2f9..1869431 100644
--- a/tests/src/Functional/Maintenance200SettingsTest.php
+++ b/tests/src/Functional/Maintenance200SettingsTest.php
@@ -20,7 +20,7 @@ class Maintenance200SettingsTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = [
+ protected static $modules = [
'block',
'maintenance200',
];
@@ -40,7 +40,7 @@ class Maintenance200SettingsTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();

$this->sut = $this
@@ -57,8 +57,8 @@ class Maintenance200SettingsTest extends BrowserTestBase {
*/
public function testSettingsForm() {
$this->drupalGet(Url::fromRoute('maintenance200_settings'));
- $this->assertRaw('Change the status code during maintenance mode', 'Checkbox found.');
- $this->assertFieldByName('maintenance200_enabled', TRUE);
+ $this->assertSession()->responseContains('Change the status code during maintenance mode');
+ $this->assertSession()->fieldValueEquals('maintenance200_enabled', TRUE);
}

/**
@@ -68,7 +68,7 @@ class Maintenance200SettingsTest extends BrowserTestBase {
$maintenance200FormUrl = Url::fromRoute('maintenance200_settings')
->toString();
$this->drupalGet(Url::fromRoute('system.site_maintenance_mode'));
- $this->assertLinkByHref($maintenance200FormUrl);
+ $this->assertSession()->linkByHrefExists($maintenance200FormUrl);
}

/**
@@ -80,12 +80,13 @@ class Maintenance200SettingsTest extends BrowserTestBase {
$edit = [
'maintenance200_enabled' => 0,
];
- $this->drupalPostForm('admin/config/development/maintenance200', $edit, t('Save configuration'));
+ $this->drupalGet('admin/config/development/maintenance200');
+ $this->submitForm($edit, t('Save configuration'));

- $this->assertRaw('The configuration options have been saved.', 'Settings saved.');
+ $this->assertSession()->responseContains('The configuration options have been saved.');

$this->drupalGet(Url::fromRoute('maintenance200_settings'));
- $this->assertFieldByName('maintenance200_enabled', FALSE);
+ $this->assertSession()->fieldValueEquals('maintenance200_enabled', FALSE);
}

}
diff --git a/tests/src/Functional/Maintenance200Test.php b/tests/src/Functional/Maintenance200Test.php
index 8a3d39e..238ea14 100644
--- a/tests/src/Functional/Maintenance200Test.php
+++ b/tests/src/Functional/Maintenance200Test.php
@@ -19,7 +19,7 @@ class Maintenance200Test extends BrowserTestBase {
*
* @var array
*/
- public static $modules = [
+ protected static $modules = [
'maintenance200',
'node',
];
@@ -32,7 +32,7 @@ class Maintenance200Test extends BrowserTestBase {
/**
* {@inheritdoc}
*/
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();

// Create Basic page node type.
@@ -63,7 +63,7 @@ class Maintenance200Test extends BrowserTestBase {
\Drupal::state()->set('system.maintenance_mode', FALSE);

$this->drupalGet('<front>');
- $this->assertResponse(200);
+ $this->assertSession()->statusCodeEquals(200);
}

/**
@@ -81,7 +81,7 @@ class Maintenance200Test extends BrowserTestBase {
->save();

$this->drupalGet('<front>');
- $this->assertResponse(503);
+ $this->assertSession()->statusCodeEquals(503);
}

/**
@@ -99,7 +99,7 @@ class Maintenance200Test extends BrowserTestBase {
->save();

$this->drupalGet('<front>');
- $this->assertResponse(200);
+ $this->assertSession()->statusCodeEquals(200);
}

/**
@@ -117,7 +117,7 @@ class Maintenance200Test extends BrowserTestBase {
->save();

$this->drupalGet('<front>');
- $this->assertResponse(418);
+ $this->assertSession()->statusCodeEquals(418);
}

}
18 changes: 18 additions & 0 deletions PATCHES/pathauto-php-82-compatibility.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/src/AliasCleaner.php b/src/AliasCleaner.php
index 20cdb6d..bbd0a7f 100644
--- a/src/AliasCleaner.php
+++ b/src/AliasCleaner.php
@@ -70,6 +70,13 @@ class AliasCleaner implements AliasCleanerInterface {
*/
protected $moduleHandler;

+ /**
+ * List of punctuation characters.
+ *
+ * @var array
+ */
+ protected $punctuationCharacters;
+
/**
* Creates a new AliasCleaner.
*
Loading