Problem/Motivation
The d7_url_alias migration runs at an arbitrary time. This has been fine. Until recently
Recently, two things happened that make this problematic:
- It's now possible to enable validation for content entity type destinations #2745797: Add option to content entity destinations for validation
- Path aliases have been converted to entities: #3009014: Convert path alias migrations to use entity:path_alias destination and … added validation logic
Combined, this means that if you enable validation for content entity destinations (and you should — see #3095456: [Plan] Discuss strategy for long-term use of entity validation in the migration system), the d7_url_alias migration runs at a time when usually no content entities have been migrated yet. Result: an enormous amount of validation errors for PathAlias entities.
Proposed resolution
Automatically enhance migrations with Path Alias entities as their destination (destination plugin entity:path_alias) to have optional dependencies on every migration that has a locatable content entity type as their destination (if it's not locatable, it can't have an URL, and there's no point in pushing Path Alias entity creation until later).
In Drupal core, this would affect the d6_url_alias and d7_url_alias migrations. But it would also automatically enhance contributed/custom migrations.
Remaining tasks
Review.
User interface changes
None. Other than: far fewer validation errors when validations are enabled.
API changes
None.
Data model changes
None.
Release notes snippet
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3098985-2.patch | 2.48 KB | wim leers |
Comments
Comment #2
wim leersComment #4
heddnAn interesting note, the path alias migration is traditionally the slowest of all migrations to execute.
Comment #5
wim leers#4: ohhh, that is interesting! Slower than node + node revision migrations? 🤯
Did the conversion of path aliases to entities make things slower? I would be super surprised if it didn't to be honest.
Comment #6
heddnContinued side note: I haven't check with the conversion to entities. But traditionally, if you are migrating a site one of the first content migrations is users. Then path aliases float pretty high in run order. And running them tends to take a _really_ long time. And it blocks all successive migrations. Pretty often I tend to cancel that migration in my testing, which leaves it in a semaphore state that shows it is running and drush let's me move on to more interesting migrations. After I can confirm all my nodes and their field data are in fact migrating correctly, then I do the right thing and migrate the entire site's content per a more normal flow.
Comment #7
wim leersWhy do path aliases need to run so early? Why does it block all successive migrations? That's not what I've seen so far, so I'm wondering what I'm missing 🤔
Comment #8
heddnStill following the rabbit trail a little... but they don't "need" to. Its just that traditionally they didn't have any validation or any dependencies. Do to lack of dependencies, they ran pretty early. They can move later if there is a _need_. Now they have an entity destination, perhaps that needs has surfaced?
Comment #9
wim leersExactly :)
Comment #10
quietone commentedThis is a different approach to dependencies, creating them as optional and in a hook migration_plugins_alter. Is this just a one off here or should we simply add the dependencies to the d6 an d7 url alias migrations? If we keep this it should be documented as to why it is different and the ymls need a comment as well.
Also, unlike other migrations this one adds dependencies on both drupal versions to d6_url_alias.yml and d7_url_alias.yml. Yes, they are added as optional so will work just fine.
The dependencies are an indexed array, this is not needed.
s/optional_migration_dependencies/locatable_entity_type_destination_migration_ids/
Comment #11
wim leersIt's because core cannot know which contrib and custom entity types a site has installed. This migration must run after all entity migrations.
Agreed :) Does the above explanation make address your concerns? Happy to add it to the patch!
Comment #12
quietone commented@Wim Leers, yes that explanation is helpful, thanks. I think comments should be added to d6_url_alias.yml, d7_url_alias.yml and path.module.
Comment #19
quietone commentedThe Migrate Drupal Module was approved for removal in #3371229: [Policy] Migrate Drupal and Migrate Drupal UI after Drupal 7 EOL.
This is Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.
The deprecation work is in #3522602: [meta] Tasks to remove Migrate Drupal module and the removal work in #3522602: [meta] Tasks to remove Migrate Drupal module.
Migrate Drupal will not be moved to a contributed project. It will be removed from core after the Drupal 12.x branch is open.