From 4c75efa68a0c86fbd0ea59fd962dd655ae20b96e Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Sun, 6 Sep 2026 11:18:16 +1000 Subject: [PATCH 1/3] [#392] Removed Drupal 10 and PHP 8.2 support. --- .github/workflows/ci.yml | 23 ------------------- CONTRIBUTING.md | 2 +- composer.json | 4 ++-- phpstan.neon | 4 ++-- rector.php | 4 ++++ src/Drupal/Driver/Core/Core.php | 14 +++++------ .../Driver/Core/Field/FieldClassifier.php | 2 +- .../Core/Field/FieldShapeClassifier.php | 2 +- src/Drupal/Driver/DrupalDriver.php | 8 +++---- .../Core/CoreBlockMethodsKernelTest.php | 9 ++++---- .../DrupalDriverConstructionKernelTest.php | 2 +- .../Tests/Driver/Unit/DrupalDriverTest.php | 6 ++--- .../Unit/Fixtures/FakeVersionDrupalDriver.php | 2 +- .../driver_field_test.info.yml | 2 +- 14 files changed, 31 insertions(+), 53 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d011b29a..cdb650f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,30 +62,12 @@ jobs: fail-fast: false matrix: include: - - php_version: '8.2' - drupal_version: '10' - deps: 'normal' - - php_version: '8.2' - drupal_version: '10' - deps: 'lowest' - - php_version: '8.3' - drupal_version: '10' - deps: 'normal' - - php_version: '8.3' - drupal_version: '10' - deps: 'lowest' - php_version: '8.3' drupal_version: '11' deps: 'normal' - php_version: '8.3' drupal_version: '11' deps: 'lowest' - - php_version: '8.4' - drupal_version: '10' - deps: 'normal' - - php_version: '8.4' - drupal_version: '10' - deps: 'lowest' - php_version: '8.4' drupal_version: '11' deps: 'normal' @@ -117,10 +99,6 @@ jobs: - name: Add Drupal core dependency run: composer require --no-interaction --dev --no-update drupal/core-recommended:^${DRUPAL_VERSION} drupal/core-composer-scaffold:^${DRUPAL_VERSION} - - name: Pin Drupal 10 tooling - if: ${{ matrix.drupal_version == '10' }} - run: composer require --no-interaction --dev --no-update mglaman/phpstan-drupal:^1.1.25 phpstan/phpstan:^1.10 phpunit/phpunit:^9.6 symfony/phpunit-bridge:^6.4 - - name: Install Composer dependencies run: | if [[ "${{ matrix.deps }}" == "lowest" ]]; then @@ -131,7 +109,6 @@ jobs: - name: Migrate PHPUnit configuration run: vendor/bin/phpunit --migrate-configuration || true - if: "${{ matrix.drupal_version == '11'}}" - name: Test with coverage if: ${{ matrix.coverage }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4b47f1f0..46df4b0f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -65,7 +65,7 @@ This repository tests the drivers and field handlers: ## Setting up the local environment Testing is performed automatically in GitHub Actions when a PR is -submitted. To execute tests locally, ensure you have PHP 8.2+ +submitted. To execute tests locally, ensure you have PHP 8.3+ installed: ```shell diff --git a/composer.json b/composer.json index 08891a88..7a48a713 100644 --- a/composer.json +++ b/composer.json @@ -21,8 +21,8 @@ ], "homepage": "http://github.com/jhedstrom/DrupalDriver", "require": { - "php": "^8.2", - "drupal/core-utility": "^10 || ^11", + "php": "^8.3", + "drupal/core-utility": "^11", "symfony/dependency-injection": "^6.4 || ^7", "symfony/process": "^6.4 || ^7" }, diff --git a/phpstan.neon b/phpstan.neon index 2b3c6d50..ca963089 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -27,8 +27,8 @@ parameters: path: src/* - # entity_test_create_bundle() is deprecated in Drupal 11.2 in favour of - # EntityTestHelper::createBundle(); kept as a fallback for Drupal 10 and - # earlier 11.x where the helper class does not yet exist. + # EntityTestHelper::createBundle(); kept as a fallback for 11.x before + # 11.2, where the helper class does not yet exist. message: '#Call to deprecated function entity_test_create_bundle\(\).*#' paths: - tests/Drupal/Tests/Driver/Kernel/Core/Field/FieldHandlerKernelTestBase.php diff --git a/rector.php b/rector.php index 960097a3..cbc28521 100644 --- a/rector.php +++ b/rector.php @@ -30,6 +30,7 @@ use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector; use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector; +use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector; use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector; use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector; use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector; @@ -67,6 +68,9 @@ ]) ->withSkip([ // Rules added by Rector's rule sets. + // Overridden methods already carry an '{@inheritdoc}' docblock, which + // the Drupal coding standard requires; the attribute repeats it. + AddOverrideAttributeToOverriddenMethodsRector::class, CatchExceptionNameMatchingTypeRector::class, ChangeSwitchToMatchRector::class, // Constructor property promotion mangles existing docblocks for the diff --git a/src/Drupal/Driver/Core/Core.php b/src/Drupal/Driver/Core/Core.php index 03ac9255..e18ef589 100644 --- a/src/Drupal/Driver/Core/Core.php +++ b/src/Drupal/Driver/Core/Core.php @@ -10,6 +10,7 @@ use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Routing\RouteObjectInterface; use Drupal\Driver\Capability\CreationAliasCapabilityInterface; use Drupal\Driver\Core\Field\DefaultHandler; use Drupal\Driver\Core\Field\FieldClassifier; @@ -222,7 +223,7 @@ protected function deriveFieldType(string $short_class_name): string { * * Subclasses override this method when they ship a version-specific * classifier. The default returns the base 'FieldClassifier' which covers - * Drupal 10 and 11. + * Drupal 11. */ protected function createFieldClassifier(): FieldClassifierInterface { return new FieldClassifier($this->getEntityFieldManager()); @@ -244,7 +245,7 @@ public function getFieldClassifier(): FieldClassifierInterface { * * Subclasses override this method when they ship a version-specific value * shape classifier. The default returns the base 'FieldShapeClassifier' which - * covers Drupal 10 and 11. + * covers Drupal 11. */ protected function createFieldShapeClassifier(): FieldShapeClassifierInterface { return new FieldShapeClassifier(); @@ -446,12 +447,9 @@ public function bootstrap(): void { $request = Request::createFromGlobals(); $kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod'); $kernel->boot(); - // A route is required for route matching. In order to support Drupal 10 - // along with 8/9, we use the hardcoded values of RouteObjectInterface - // constants ROUTE_NAME and ROUTE_OBJECT. - // @see https://www.drupal.org/node/3151009 - $request->attributes->set('_route_object', new Route('')); - $request->attributes->set('_route', ''); + // Route matching requires a route on the request. + $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('')); + $request->attributes->set(RouteObjectInterface::ROUTE_NAME, ''); $kernel->preHandle($request); diff --git a/src/Drupal/Driver/Core/Field/FieldClassifier.php b/src/Drupal/Driver/Core/Field/FieldClassifier.php index 13e6f72d..7e861bf3 100644 --- a/src/Drupal/Driver/Core/Field/FieldClassifier.php +++ b/src/Drupal/Driver/Core/Field/FieldClassifier.php @@ -9,7 +9,7 @@ use Drupal\field\Entity\FieldStorageConfig; /** - * Default Drupal 10/11 field classifier. + * Default Drupal 11 field classifier. * * See 'src/Drupal/Driver/Core/Field/README.md' for the full truth table. */ diff --git a/src/Drupal/Driver/Core/Field/FieldShapeClassifier.php b/src/Drupal/Driver/Core/Field/FieldShapeClassifier.php index 550205e1..162d6d10 100644 --- a/src/Drupal/Driver/Core/Field/FieldShapeClassifier.php +++ b/src/Drupal/Driver/Core/Field/FieldShapeClassifier.php @@ -10,7 +10,7 @@ use Drupal\Core\TypedData\ListDataDefinitionInterface; /** - * Default Drupal 10/11 value-shape classifier. + * Default Drupal 11 value-shape classifier. * * See 'src/Drupal/Driver/Core/Field/README.md' for the value-shape axis and how * 'Core' consumes it during handler selection. diff --git a/src/Drupal/Driver/DrupalDriver.php b/src/Drupal/Driver/DrupalDriver.php index 084357b3..ab4f2995 100644 --- a/src/Drupal/Driver/DrupalDriver.php +++ b/src/Drupal/Driver/DrupalDriver.php @@ -115,7 +115,7 @@ public function setCoreFromVersion(): void { $version = $this->getDrupalVersion(); $candidates = []; - for ($n = $version; $n >= 10; $n--) { + for ($n = $version; $n >= 11; $n--) { $candidates[] = sprintf('Drupal\\Driver\\Core%d\\Core', $n); } @@ -441,8 +441,8 @@ protected function detectMajorVersion(): int { throw new BootstrapException(sprintf('Unable to extract major Drupal core version from version string %s.', $version_string)); } - if ((int) $major < 10) { - throw new BootstrapException(sprintf('Unsupported Drupal core version %s. Drupal 10 or higher is required.', $version_string)); + if ((int) $major < 11) { + throw new BootstrapException(sprintf('Unsupported Drupal core version %s. Drupal 11 or higher is required.', $version_string)); } return (int) $major; @@ -452,7 +452,7 @@ protected function detectMajorVersion(): int { * Reads the Drupal VERSION constant. * * Subclasses override this to return a synthetic version for testing the - * non-numeric and sub-10 branches of 'detectMajorVersion()'. + * non-numeric and sub-11 branches of 'detectMajorVersion()'. */ protected function readVersionConstant(): string { return \Drupal::VERSION; diff --git a/tests/Drupal/Tests/Driver/Kernel/Core/CoreBlockMethodsKernelTest.php b/tests/Drupal/Tests/Driver/Kernel/Core/CoreBlockMethodsKernelTest.php index a8eb9632..034f3a5d 100644 --- a/tests/Drupal/Tests/Driver/Kernel/Core/CoreBlockMethodsKernelTest.php +++ b/tests/Drupal/Tests/Driver/Kernel/Core/CoreBlockMethodsKernelTest.php @@ -47,11 +47,10 @@ protected function setUp(): void { parent::setUp(); $this->installEntitySchema('user'); $this->installEntitySchema('block_content'); - // Only 'system' config is installed. Installing 'block_content' config - // on Drupal 10 / Drupal 11-lowest pulls in - // 'field.storage.block_content.body', whose schema references the 'text' - // module - unnecessary surface for this test, which creates its own - // body-less 'block_content_type' inline. + // Only 'system' config is installed. Installing 'block_content' config on + // Drupal 11-lowest pulls in 'field.storage.block_content.body', whose + // schema references the 'text' module - unnecessary surface for this test, + // which creates its own body-less 'block_content_type' inline. $this->installConfig(['system']); \Drupal::service('theme_installer')->install(['stark']); $this->core = new Core($this->root); diff --git a/tests/Drupal/Tests/Driver/Kernel/DrupalDriverConstructionKernelTest.php b/tests/Drupal/Tests/Driver/Kernel/DrupalDriverConstructionKernelTest.php index 2ab7bd0e..53cdd31f 100644 --- a/tests/Drupal/Tests/Driver/Kernel/DrupalDriverConstructionKernelTest.php +++ b/tests/Drupal/Tests/Driver/Kernel/DrupalDriverConstructionKernelTest.php @@ -40,7 +40,7 @@ public function testConstructorDetectsVersion(): void { $version = $driver->getDrupalVersion(); - $this->assertGreaterThanOrEqual(10, $version, 'Driver should detect Drupal 10 or higher.'); + $this->assertGreaterThanOrEqual(11, $version, 'Driver should detect Drupal 11 or higher.'); } /** diff --git a/tests/Drupal/Tests/Driver/Unit/DrupalDriverTest.php b/tests/Drupal/Tests/Driver/Unit/DrupalDriverTest.php index c0434390..65c74415 100644 --- a/tests/Drupal/Tests/Driver/Unit/DrupalDriverTest.php +++ b/tests/Drupal/Tests/Driver/Unit/DrupalDriverTest.php @@ -95,13 +95,13 @@ public function testDetectMajorVersionRejectsNonNumeric(): void { } /** - * Tests that 'detectMajorVersion()' rejects pre-10 versions. + * Tests that 'detectMajorVersion()' rejects pre-11 versions. */ - public function testDetectMajorVersionRejectsPre10(): void { + public function testDetectMajorVersionRejectsPre11(): void { $this->expectException(BootstrapException::class); $this->expectExceptionMessageMatches('/Unsupported Drupal core version/'); - FakeVersionDrupalDriver::$nextVersion = '9.5.0'; + FakeVersionDrupalDriver::$nextVersion = '10.4.0'; new FakeVersionDrupalDriver(__DIR__, 'default'); } diff --git a/tests/Drupal/Tests/Driver/Unit/Fixtures/FakeVersionDrupalDriver.php b/tests/Drupal/Tests/Driver/Unit/Fixtures/FakeVersionDrupalDriver.php index 5c90c973..8c6bb94d 100644 --- a/tests/Drupal/Tests/Driver/Unit/Fixtures/FakeVersionDrupalDriver.php +++ b/tests/Drupal/Tests/Driver/Unit/Fixtures/FakeVersionDrupalDriver.php @@ -11,7 +11,7 @@ * * The parent constructor calls 'detectMajorVersion()' which in turn calls * 'readVersionConstant()'. Overriding the latter lets tests exercise the - * malformed-version and sub-10 branches without mutating '\Drupal::VERSION'. + * malformed-version and sub-11 branches without mutating '\Drupal::VERSION'. */ class FakeVersionDrupalDriver extends DrupalDriver { diff --git a/tests/fixtures/modules/driver_field_test/driver_field_test.info.yml b/tests/fixtures/modules/driver_field_test/driver_field_test.info.yml index 4b4fab0c..20c5fa47 100644 --- a/tests/fixtures/modules/driver_field_test/driver_field_test.info.yml +++ b/tests/fixtures/modules/driver_field_test/driver_field_test.info.yml @@ -2,4 +2,4 @@ name: 'Driver field test' type: module description: 'Provides custom field types with no driver handler, for kernel tests.' package: Testing -core_version_requirement: ^10 || ^11 +core_version_requirement: ^11 From fcc608b61bbc909a0e068bd6ae5f1ce16899407d Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Sun, 6 Sep 2026 11:18:22 +1000 Subject: [PATCH 2/3] [#392] Documented the supported version matrix and the 3.x security support window. --- README.md | 14 +++++++++----- UPGRADING.md | 16 ++++++++++++++-- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c488c3d9..dc01ae20 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,15 @@ A collection of lightweight drivers with a common interface for interacting with [Drupal](https://www.drupal.org). These are generally intended for testing and are not meant to be API-complete. -> **Note:** v3 supports Drupal 10 and 11 on PHP 8.2+. Sites that -> need Drupal 7 or PHP 8.1 should pin to the -> [`2.x` branch](https://github.com/jhedstrom/DrupalDriver/tree/2.x). -> See [UPGRADING.md](UPGRADING.md) for the v2 to v3 migration -> guide. +## Supported versions + +| Version | Drupal | PHP | Support | +| --- | --- | --- | --- | +| 4.x | 11 | 8.3, 8.4 | Active development | +| 3.x | 10, 11 | 8.2, 8.3, 8.4 | Security fixes only until 1 July 2027. 3.4 is the final release. | +| 2.x | 8, 9, 10, 11 | 7.4+ | Unsupported | + +See [UPGRADING.md](UPGRADING.md) for migration guides. ## Drivers diff --git a/UPGRADING.md b/UPGRADING.md index 9acb91b0..f3d59298 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -1,5 +1,17 @@ # Upgrading +## From v3 to v4 + +### Platform requirements + +- PHP `^8.3` (was `^8.2`). +- Drupal `^11` (was `^10 || ^11`). `DrupalDriver::detectMajorVersion()` throws a + `BootstrapException` when it detects Drupal < 11, and + `DrupalDriver::setCoreFromVersion()` stops walking the `Drupal\Driver\Core{N}\Core` + lookup chain at `Core11`. +- Sites on Drupal 10 or PHP 8.2 should pin to `^3.4`, which receives security + fixes only. See the support table in [README.md](README.md). + ## From v2 to v3 v3 reworks the driver contract into a set of composable capability interfaces, @@ -16,8 +28,8 @@ updating. detects Drupal < 10. - Symfony `^6.4 || ^7` for `dependency-injection`, `process`, and `phpunit-bridge`. -- Sites that need to stay on PHP 8.1 or Drupal 9 should pin to the 2.x line, - now maintained on the `2.x` branch. `master` is the active 3.x branch. +- Sites that need to stay on PHP 8.1 or Drupal 9 have no supported option: the + 2.x line is unsupported. ### Namespace and source layout changes From e7efa1e2f657917aee7025b4a441c6cb932968c4 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Sun, 6 Sep 2026 11:42:48 +1000 Subject: [PATCH 3/3] [#392] Switched Rector to the Drupal 11 deprecation set. --- composer.json | 2 +- rector.php | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 7a48a713..7e5320ed 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ "ergebnis/composer-normalize": "^2.50", "mglaman/phpstan-drupal": "^2.0", "mikey179/vfsstream": "^1.6.11", - "palantirnet/drupal-rector": "^0.21.1", + "palantirnet/drupal-rector": "^1.1.3", "php-parallel-lint/php-parallel-lint": "^1.0", "phpspec/prophecy-phpunit": "^2", "phpstan/extension-installer": "^1.4", diff --git a/rector.php b/rector.php index cbc28521..6face45b 100644 --- a/rector.php +++ b/rector.php @@ -11,14 +11,15 @@ declare(strict_types=1); use DrupalFinder\DrupalFinderComposerRuntime; -use DrupalRector\Set\Drupal10SetList; +use DrupalRector\Rector\Deprecation\FunctionToStaticRector; +use DrupalRector\Rector\PHPUnit\PhpUnitAddRunTestsInSeparateProcessesAttributeRector; +use DrupalRector\Set\Drupal11SetList; use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector; use Rector\CodeQuality\Rector\ClassMethod\InlineArrayReturnAssignRector; use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector; use Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector; use Rector\CodingStyle\Rector\ClassLike\NewlineBetweenClassLikeStmtsRector; use Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector; -use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector; use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector; use Rector\Config\RectorConfig; use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector; @@ -60,7 +61,7 @@ earlyReturn: TRUE, ) ->withSets([ - Drupal10SetList::DRUPAL_10, + Drupal11SetList::DRUPAL_11, ]) ->withRules([ DeclareStrictTypesRector::class, @@ -77,7 +78,6 @@ // promoted parameter and trips PHPCS multi-line declaration sniffs. ClassPropertyAssignToConstructorPromotionRector::class, CompleteDynamicPropertiesRector::class, - CountArrayToEmptyArrayComparisonRector::class, DisallowedEmptyRuleFixerRector::class, InlineArrayReturnAssignRector::class, NewlineAfterStatementRector::class, @@ -90,6 +90,12 @@ RenameVariableToMatchMethodCallReturnTypeRector::class, RenameVariableToMatchNewTypeRector::class, SimplifyEmptyCheckOnEmptyArrayRector::class, + // Wraps a call that is already guarded by 'class_exists()' in a second + // version check, so the version is tested twice for one call. + FunctionToStaticRector::class, + // Isolating every kernel test in its own process multiplies the suite + // runtime; the tests share no mutable global state. + PhpUnitAddRunTestsInSeparateProcessesAttributeRector::class, // Breaks 'drupal_static()' caching in 'Core::getAllPermissions()': // assigning into the static reference is required for subsequent // calls to hit the cache, so the intermediate variable is not dead