Problem/Motivation

Drupal 12 can now be tested on Gitlab CI with the PHPUNIT next major job.

Add Drupal API and PHP compatibility changes to support Drupal 12.

Steps to reproduce

Proposed resolution

In the same development branch 2.2.x, as compatibility for older core versions should stay the same: 10.3 min.

Among some of the expected changes:

  • Update module's core version requirement to: core_version_requirement: ^10.3 || 11 || ^12
  • Move all .module file's hooks to a Hook class with PHP attributes
  • Add types to all function signatures and declare strict types
  • Normalize composer.json file
  • Any other changes

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dydave created an issue. See original summary.

  • dydave committed bfb79f52 on 2.2.x
    Issue #3605986 by dydave: Added support for Drupal 12, code clean-up and...
dydave’s picture

Status: Active » Fixed

Quick follow-up on this issue:

Core version requirements were raised to Drupal 12. 🥳
In other words, current versions are still supported exactly the same way, but the mode can now also be used on Drupal 12.

Removed a lot of code, in particular in field formatter plugin classes, where the __constructor and create methods could be removed.
The create method was refactored and moved to the Trait.

Added PHP Attributes Group and RunTestsInSeparateProcesses in Tests and had to keep the @group

Enabled Upgrade status job in gitlab CI.

PHPSTAN validation jobs for 3 major core versions:

Had a few issues getting phpstan jobs working for previous major (10.6.x) and next major (12.x):

Based on #3545263: Fix PHPStan for previous major, I was able to find a few solutions:
a. For previous major: D10.6.x errors being raised due to added PHP Attributes in Tests files: Group and RunTestsInSeparateProcesses .

The solution was found in:
https://git.drupalcode.org/project/smart_trim/-/merge_requests/116/diffs...
Which was to add before script commands to remove the problematic pieces of code before running phpstan for the previous major build, see:
https://git.drupalcode.org/project/image_link_formatter/-/blob/2.2.1/.gi...

b. For next major: D12.x errors being raised du to:

  170    Cannot call method get() on                                            
         Drupal\Core\DependencyInjection\ContainerBuilder|null.                 
         🪪  method.nonObject  

Corresponding to calling $this->container->get in the Kernel tests files and the solution was to ignore these specific lines.

Rounds of improvements suggested by AI

On my local environment, I worked with an AI agent which suggested several interesting additional changes that I considered, reviewed and tested: Code style improvements, performance, security, etc...

Note that I checked whether issue #3064751: Responsive image formatter does not support URL/Link options was fixed corresponding to a @todo in the Image Link Formatter Kernel tests:
The changes have not yet been integrated to the 11.3.x branch.
In other words, the issue is fixed but will only be available with D11.4.x and above.

We can probably come back to this @todo task a little bit later, once the first 11.4.x stable releases are avaiblable.
 

Since all the jobs and tests were still passing 🟢, I went ahead and merged the changes above at #3. 🥳

The changes were published in the new release image_link_formatter-2.2.1 which is now compatible with Drupal 12.

Lastly, the pipelines schedules were updated at:
https://git.drupalcode.org/project/image_link_formatter/-/pipeline_sched...
Two automated builds are now in place:

  • Twice a month: Development: 2.2.x with a full autorun of all possible jobs.
  • Once a month: Deprecation build: 2.2.1x tested with 10.3.x.

 

Since all the work to be carried in this ticket should have been completed at this point, marking it as Fixed for now.

Feel free to let us know if you have any questions or concerns on any of the recent code changes, or the project in general, we would surely be glad to help.
Thanks in advance.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.