Issue #3616501: Modernize the module for Drupal 11.2+ and Drupal 12

Drupal 12 readiness:

  • Replace the $entity->original property, which is removed in Drupal 12.0.0, with EntityInterface::getOriginal(). This also guards against a NULL original, which previously caused a fatal error. Because getOriginal() was added in Drupal 11.2, core_version_requirement becomes ^11.2 || ^12 and support for Drupal 9 and 10 is dropped.

Coding standards and structure:

  • Move the hook implementations out of the .module file into class based hooks using the #[Hook] attribute, and remove the .module file entirely. The module now declares skip_procedural_hook_scan so core does not scan it for procedural hooks.
  • Extract the webhook logic into the page_refresh_webhook.trigger service behind PageRefreshWebhookTriggerInterface, so it can be injected and decorated. The service uses the logger channel that was already declared but never used, instead of \Drupal::logger().
  • Move PageRefreshWebhookTriggerInstruction out of the global namespace into Drupal\page_refresh_webhook and rename its cases to PascalCase. This removes the phpcs:ignore directives and is the only breaking change; see the upgrade notes in README.md.
  • Add declare(strict_types=1), parameter and return types throughout.
  • Fix the api.php file, which had a duplicated @file block and documented a hook name that does not exist.

Configuration:

  • Add the missing config schema and default configuration.
  • Store the crawl depth as an integer. The select element submitted a string while the fallback used an integer, so the payload type depended on how the module was configured. hook_update_11201() converts existing configuration.
  • Always write content_types as an array so the key stays present.

Robustness:

  • Catch \Throwable rather than \Exception, so an error while building the request URL can no longer interrupt saving content.

Tooling and tests:

  • Add kernel test coverage for the trigger service and the settings form.
  • Add phpcs.xml.dist including PHPCompatibility for the whole supported PHP range, phpstan.neon, a GitLab CI configuration and a .gitignore.

Closes #3616501

Merge request reports

Loading
Loading