Problem/Motivation

Migrate commands including `drush migrate:status` fail when Pathauto is installed in Drupal 11, due to a Pathauto error:

```
In MigrationPluginManager.php line 118:

The pathauto_pattern plugin must define the source_module property.
```

Steps to reproduce

Set up a migration. Make sure Pathauto is installed, install all Migrate modules, attempt `drush migrate:status`.

Proposed resolution

In the file `/src/Plugin/migrate/source/PathautoPattern.php`:

at line 22, make the following change:

```
#[MigrateSource(
- id: 'pathauto_pattern'
+ id: 'pathauto_pattern',
+ source_module: 'pathauto',
)]
```

This allows migration commands to proceed.

Issue fork pathauto-3635649

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

bondjimbond created an issue. See original summary.

realsp made their first commit to this issue’s fork.

realsp’s picture

Assigned: Unassigned » realsp

Thanks for the report, @bondjimbond. I reproduced it on Drupal 11.4.8 with Pathauto 8.x-1.15: enabling migrate_drupal is enough, and every migrate command, including drush migrate:status, then fails with: The pathauto_pattern plugin must define the source_module property.

Already fixed in 8.x-1.x, but not released

This is the same error as #3588684 (https://www.drupal.org/project/pathauto/issues/3588684). That issue added source_module: pathauto to migrations/d7_pathauto_patterns.yml, and it was committed to 8.x-1.x in June, after 1.15 came out. Until there is a new release, you can use 8.x-1.x-dev or apply the MR from #3588684. I checked that on 8.x-1.x (fb071b9), drush migrate:status works again.

The proposed change doesn't work

Core's #[MigrateSource] attribute has no source_module parameter, so adding it breaks plugin discovery:
Error: Unknown named parameter $source_module in ReflectionAttribute->newInstance() (line 22 of.../src/Plugin/migrate/source/PathautoPattern.php)

What's still broken on 8.x-1.x

The actual cause is in PathautoPattern.php. It has both a @MigrateSource annotation, which sets source_module = "pathauto", and a #[MigrateSource] attribute, which was added in #3553071 (https://www.drupal.org/project/pathauto/issues/3553071). Core reads the attribute first and ignores the annotation, so the plugin definition has no source_module. The YAML change in #3588684 only fixes the bundled migration. Any other migration tagged "Drupal 7" that uses plugin: pathauto_pattern without its own source_module (a custom or migrate_plus migration, for example) still fails on 8.x-1.x. I confirmed this with a small test migration.

Removing the attribute and keeping the annotation fixes it: both the bundled and the custom migration load, and the definition has source_module:pathauto. This is also what core does: its Drupal 7 source plugins (for example node/src/Plugin/migrate/source/d7/Node.php) still use annotations only, because the attribute can't carry source_module.

Next steps
@bondjimbond, was the migration you set up your own migration using the pathauto_pattern source plugin? If so, you'll hit the remaining problem even on 8.x-1.x, and this issue is worth keeping open for the fix above. If not, this is a duplicate of #3588684, and what you need is a new release.

Maintainers: if you agree, I can open an MR on this issue that removes the attribute (keeping the annotation and the YAML line) and adds a Kernel test checking that pathauto_pattern has source_module. I'd also suggest updating the issue title and summary to describe that remaining problem.

AI disclosure
Investigated with help from Claude Code; results verified manually.

realsp’s picture

Status: Active » Needs review
bondjimbond’s picture

@realsp

was the migration you set up your own migration using the pathauto_pattern source plugin?

It was my own migration, without any specific reference to pathauto - migrating a custom content type with very few fields. Pathauto just gets in the way of any migration at all.

berdir’s picture

Version: 8.x-1.15 » 8.x-1.x-dev
Status: Needs review » Closed (duplicate)

This has already been fixed in dev and is now in 8.x-1.16

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

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

Maintainers, credit people who helped resolve this issue.