Problem/Motivation
With Drupal 11.x, the migrate_plus module throws a TypeError when enabling modules:
TypeError: migrate_plus_module_implements_alter(): Argument #2 ($hook) must be of type string, int given, called in /core/lib/Drupal/Core/Hook/HookCollectorPass.php on line 239 in migrate_plus_module_implements_alter() (line 99 of /modules/contrib/migrate_plus/migrate_plus.module).
This is caused by core issue #3508292 where update hooks are incorrectly being registered as normal hooks, causing the HookCollectorPass to pass integers (from update hook numbers) instead of strings to hook_module_implements_alter() implementations.
Steps to reproduce
1. Install Drupal 11.x
2. Install migrate_plus module
3. Try to install additional modules or clear cache
4. Observe the TypeError
Environment
- Drupal core: 11.2.4
- Migrate Plus: 6.0.8
- PHP: 8.3.25
Proposed resolution
Add type checking in migrate_plus_module_implements_alter() to handle cases where $hook is an integer. Since migrate_plus only processes specific string hook names, return early when $hook is not a string.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork migrate_plus-3547891
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
tarawij commentedI’ve prepared a merge request with a fix for this error:
MR !143: Fix TypeError in migrate_plus_module_implements_alter()
The patch adds a type check to ensure $hook is a string before processing, preventing the fatal error caused when integers are passed (see core issue #3508292).
This patch is a workaround for Drupal core issue #3508292. The guard prevents fatal errors in Migrate Plus until the core fix lands. Once the core issue is resolved, this workaround may be removed.
Comment #4
heddnComment #5
heddnThanks for the quick fix here.