Problem/Motivation
When running any migrate command (e.g. drush migrate:status) on a Drupal 11 site that has migrate_drupal enabled, the following error is thrown even if the
d7_pathauto_patterns migration is not being used:
In MigrationPluginManager.php line 118:
The pathauto_pattern plugin must define the source_module property. Steps to reproduce
1. Drupal 11 site with pathauto and migrate_drupal enabled
2. Run drush migrate:status
3. Error is thrown
Root cause
In Drupal 11, PHP 8 attributes take precedence over docblock annotations for plugin discovery. The PathautoPattern source plugin
(src/Plugin/migrate/source/PathautoPattern.php) was partially migrated to use the #[MigrateSource] attribute, but source_module was not carried over:
// Old annotation (ignored in Drupal 11):
// @MigrateSource(id = "pathauto_pattern", source_module = "pathauto")
// New attribute (missing source_module):
#[MigrateSource(id: 'pathauto_pattern')]
Drupal\migrate_drupal\MigrationPluginManager::processDefinition() checks for source_module either in the source plugin definition or in the migration's source section. Since
the PHP 8 attribute doesn't include it and the MigrateSource attribute class itself has no source_module parameter, the check fails.
Proposed resolution
Add source_module: pathauto to the source section of migrations/d7_pathauto_patterns.yml:
source:
plugin: pathauto_pattern
source_module: pathauto
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork pathauto-3588684
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
joegraduateComment #4
fchometonWorks for me on Drupal 11.3.8
Comment #5
pacproduct commentedWorks for me on Drupal 11.3.9.
Comment #6
trebormcConfirming the patch works as expected on Drupal core 11.3.9. drush mim runs without errors now. Thanks for the fix!