Problem/Motivation
On Drupal 11, drush updb or cache rebuild can fail with:
TypeError: ... invokeAllWith(): Argument #1 ($hook) must be of type callable, string given
This happens when the procedural hook replicate_ui_entity_type_build() is registered but the .module file is not loaded during the update kernel/container rebuild, so the listener is a string that is not callable.
Steps to Reproduce
Enable replicate_ui on Drupal 11.
Run drush updb or trigger a cache rebuild during update.
Observe the TypeError from ModuleHandler::invokeAllWith().
Proposed Resolution (D10 + D11 BC)Add an attribute‑based hook listener for entity_type_build that calls the existing Drupal\replicate_ui\Hooks\EntityTypeBuild::build() method.
Keep the procedural function for Drupal 10, but annotate it with #[LegacyHook] so Drupal 11 does not register it as a listener.
Expected Result
Drupal 11: no crash during drush updb / cache rebuild; entity types remain configured.
Drupal 10: behavior unchanged.
Acceptance Criteria
drush updb runs cleanly on Drupal 11 with replicate_ui enabled.
hook_entity_type_build logic still executes (replicate link templates set).
Drupal 10 continues using procedural hook without errors or behavior changes.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | replicate_ui-3572012.patch | 1.83 KB | tiberiu.dumitru23 |
Issue fork replicate_ui-3572012
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
tiberiu.dumitru23 commentedPatch attached.
Comment #6
aaron gil martinez commentedChanges look good to me. +1
Comment #7
berdirI'm fine with converting to OOP hooks, but then lets do all of them.
FWIW, this is just a workaround of a deeper issue in core, see #3207813: ModuleHandler skips all hook implementations when invoked before the module files have been loaded and related issues.
Comment #11
berdirThanks for sticking with this. This looks good to me, I would moved the entity operations hook below the other one purely because this makes the diff pretty hard to read, but that's super nitpicky and I'm fine getting this in like this.
Merged.
If you want to move changes you had here for phpcs and cspell into their own issues then I think we can get them in too. That would be a good cleanup before starting the 2.x version that will require 11.2 and drop the replicate dependency in favor of the core duplicate hook.