Added support for Drupal 12: core version requirements, the contrib Toolbar...

Summary

Adds Drupal 12 support: ^10.3 || ^11 || ^12. Drupal 10.3 and above stay supported.

Issue: https://www.drupal.org/project/admin_toolbar/issues/3594696

Changes

Core compatibility

  • core_version_requirement: ^10.3 || ^11 || ^12 in the info files of the 3 modules and the 5 test modules.
  • admin_toolbar_links_access_filter is left as is: still a stub for one more minor, with its core_version_requirement unchanged.
  • hook_requirements() of admin_toolbar_links_access_filter no longer uses REQUIREMENT_ERROR (removed in Drupal 12). It uses the RequirementSeverity enum when it exists.

Composer

  • Requires drupal/toolbar (*), since the Toolbar module is no longer part of Drupal 12 core.
  • Removes the provide entry for drupal/toolbar.

Object oriented hooks

  • Hooks are now #[Hook] methods in src/Hook/ classes:
    • AdminToolbarHooks
    • AdminToolbarSearchHooks
    • AdminToolbarToolsHooks
  • The procedural implementations in the .module files are kept as #[LegacyHook] stubs calling the hook class services, so Drupal 10.3 keeps working.
  • The hook classes are registered as services in the *.services.yml files. This is required below Drupal 11.1.
  • admin_toolbar_tools.menu_link_rebuild_manager is injected as a service closure, so it is only instantiated when needed.
  • Update hooks stay procedural.

Tests

  • #[Group] attributes added next to the @group annotations. The annotations are kept because test discovery in core below 11.2 requires them.
  • #[CoversClass] replaces @covers in the two unit tests.
  • #[RunTestsInSeparateProcesses] added to the Kernel, Functional and FunctionalJavascript test classes (required by Drupal 12 core).
  • Mocks without expectations replaced with stubs (PHPUnit 12 notices).
  • AdminToolbarToolsExtraLinksTest enables contact only when the module is found (core below 12, or the contrib module), and skips the contact_form checks otherwise.

GitLab CI

  • Opted in to the next major jobs (OPT_IN_TEST_NEXT_MAJOR, RUN_JOB_UPGRADE_STATUS).
  • The "composer (next major)" job requires drupal/automatic_updates, drupal/project_browser and drupal/contact. Each is allowed to fail, and their tests are skipped when no compatible version exists.
  • The "phpstan (previous major)" job strips the attributes unavailable on Drupal 10 (#[Group], #[Hook], #[LegacyHook], etc.) with two sed commands.

Testing

  • All GitLab CI jobs pass, including the next major (12.x) PHPUnit and PHPStan jobs and the previous major (10.6.x) PHPStan job.
  • Tested locally on Drupal 11.5.
  • The search autocomplete still relies on the jQuery UI autocomplete bundled in the core drupal.autocomplete library, which is still present in core main. The next major JavaScript tests pass.
  • Not tested manually on a Drupal 12 site.

Notes for the release

  • Sites must have drupal/toolbar available on Drupal 12 (Composer requires it).
Edited by David Suissa

Merge request reports

Loading
Loading