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

Command icon 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

tarawij created an issue. See original summary.

tarawij’s picture

Issue summary: View changes

I’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.

heddn’s picture

Status: Active » Needs review
heddn’s picture

Status: Needs review » Fixed

Thanks for the quick fix here.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

  • heddn committed 90de1377 on 6.0.x authored by tarawij
    [#3547891] feat: Fatal error in migrate_plus_module_implements_alter()...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.