Problem/Motivation
On PHP 8.4, the #[\Deprecated] attribute triggers E_USER_DEPRECATED automatically at runtime whenever an annotated method or constant is accessed. Seven #[\Deprecated] attributes on reusable block deprecation hooks cause excessive watchdog entries and on-screen warnings on every page load when system.logging.error_level is set to verbose.
On PHP 8.3 and earlier, #[\Deprecated] was silently ignored by the engine, so these attributes had no runtime effect. The class docblock on ReusableBlockHooks explicitly states that trigger_error() was intentionally omitted to avoid per-request noise, but the PHP 8.4 attribute behavior reintroduced that exact noise through a different path.
Affected locations:
ReusableBlockHooks: 4 hook methods (entityTypeAlter,contextualLinksAlter,localTasksAlter,menuLocalActionsAlter)PatternkitEnvironment:FEATURE_ENABLE_REUSABLE_BLOCKSconstantPatternkitBlockderivative:getReusableBlockDerivatives()method
These hooks fire on every request regardless of whether the reusable blocks feature is enabled. The hooks early-return when the feature is off, but the #[\Deprecated] attribute triggers before the method body executes.
Steps to reproduce
- Run Patternkit on PHP 8.4 with Drupal 11.4.
- Set
system.logging.error_leveltoverbose. - Visit any page.
- Check the Drupal log at
/admin/reports/dblogfiltered to typephp. - Observe multiple
E_USER_DEPRECATEDentries per page load fromReusableBlockHooksmethods and theFEATURE_ENABLE_REUSABLE_BLOCKSconstant.
Proposed resolution
Remove all 7 #[\Deprecated] attributes from the three affected files. Update the ReusableBlockHooks class docblock to reflect that runtime attributes are no longer used.
The existing deprecation signals remain intact:
@deprecateddocblocks on all affected classes, methods, and constants (IDE and static analysis visibility)- The
hook_requirements()warning on/admin/reports/statuswhen reusable blocks exist in the database (site operator visibility)
Drupal core has not yet established guidance on #[\Deprecated] attribute usage for hooks (#3479340: Adopt #[\Deprecated] attribute). The PHP RFC explicitly leaves per-request noise suppression out of scope, making the attribute unsuitable for hooks that fire on every page load. This decision can be revisited once core establishes a convention.
Remaining tasks
- Review and test the merge request.
User interface changes
Deprecation warnings no longer appear on every page load for sites using verbose error logging on PHP 8.4. The status report warning on /admin/reports/status is unchanged.
Introduced terminology
None.
API changes
None. @deprecated docblocks remain in place. No behavior, interface, or public API change.
Data model changes
None.
Release notes snippet
Removed PHP 8.4 #[\Deprecated] attributes from reusable block deprecation hooks that caused excessive E_USER_DEPRECATED watchdog noise on every page load. The @deprecated docblocks and status report warning remain as the intended deprecation signals.
Issue fork patternkit-3609394
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
Comment #3
sluceroReady for review.
The PHPStan failure has a fix already that will be merged in alongside work in #3608056: Update Drupal 11.4 Hook Attribute Compatibility.
Comment #5
sluceroMerged for inclusion in the 9.1.3 release.
See #3542304: Patternkit 9.1.3 Release Plan.