Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
When one wants to do a partial site migrations (e.g. migrate node articles only, but nothing else), it would be nice to provide an option for migrating only those metatag settings whose destination is an article node.
Proposed resolution
Derive path redirect migrations per entity type (and bundle), at least for nodes and taxonomy terms.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#19 | interdiff.txt | 772 bytes | Wim Leers |
#19 | 3169952-19.patch | 19.95 KB | Wim Leers |
| |||
#13 | 3169952-12-13.patch | 19.91 KB | Wim Leers |
#13 | interdiff.txt | 9.09 KB | Wim Leers |
#12 | 3169952-9-12.patch | 27.26 KB | Wim Leers |
Comments
Comment #2
tim.plunkettHere is a very rough first attempt, and only for one of the 3 migrations
This is built on top of #3165112: Metatag migrations should be tagged "Configuration"
Comment #4
DamienMcKenna#3165112 has been committed.
Comment #5
Wim LeersLovely, thank you @DamienMcKenna! When are you planning another release?
Comment #6
DamienMcKennaI don't have another release currently planned.
Comment #7
tim.plunkettHere's some incremental progress.
Fixed the above failure (I hope!)
Comment #8
tim.plunkettFixing the dependency between the two migrations
Comment #9
Wim LeersThis is unfortunately nowhere not quite ready yet 😔
I started reviewing and improving #7 this morning. In the mean time, @tim.plunkett has posted #8.
Here's a partial review plus reroll with lots of fixes. It's still not fully finished though. In particular, the migration dependencies need a lot more attention. And
d7_metatag_field_instance_widget_settings
has not yet been updated at all yet …When
$target_entity_type_id === 'node'
and$target_entity_bundle === 'article'
(for example), this will result in$content_entity_migration_id == 'd7_node_complete'
, which is just the base plugin ID.That next
if
-test does take into account the bundle. So this patch is compatible with Drupal core, but not with Drupal core plus #3097336: Improve the DX for migrating content entities: view modes, fields, formatters, widgets etc should be migrated per entity type + bundle applied.(The
d7_node_complete
migration "disappears" and only derived ones remain when that is applied.)Let's make this compatible with both an unpatched Drupal core and this core patch.
Precise dependencies being added here means we should remove this from
d7_metatag_field_instance.yml
This is not used.
c/p leftover
This assumes that all source entity types also exist on the destination site — if they don't, this will cause the migration deriver to crash.
This is blindly adding the
other
case. It should only be added if there indeed is an "other".See #3051251-14: Existing menu links show validation issues on migration (and ALL menu links pointing to node translations are invalid) or #3122649-34: [PP-2] Derive path alias migrations per entity type (and bundle) for an example.
Furthermore, this is a migration definition which is not actually restricting the source plugin to those which are "other".
EDIT: upon closer inspection, metatags can by definition only be applied to entities. Therefore the "other" derivative doesn't really make sense here, unlike for the path alias and path redirect migrations (the latter of which is the origin for much of this code). Because paths are independent of entities, a "other" category is necessary. No such restriction is needed here! 😊
Yay for simplification! :D
c/p leftover
c/p leftover
Debug leftover 🤓
⚠️ These restrictions are not yet being respected by
\Drupal\metatag\Plugin\migrate\source\d7\MetatagFieldInstance
— and for that reason every derivative still returns all metatag field instances as rows to migrate.Comment #10
Wim Leers#8:
We can't just remove this, that could break existing migrations. We just need to refine this in the deriver! Existing migrations won't inherit the deriver, so they'll be fine.
I see you noticed this was wrong, as I pointed out in #9.1 🤓👍
This assumes that #3097336: Improve the DX for migrating content entities: view modes, fields, formatters, widgets etc should be migrated per entity type + bundle is applied, which we cannot. (See #9.1 again.)
What's the purpose of this? 🤔
Comment #12
Wim LeersThis solves all that.
Interdiff explained:
This was necessary to make it work for both
d7_metatag_field_instance
andd7_metatag_field_instance_widget_settings
.This should still be generalized to other entity types, but it it covers the same set of explicitly supported integrations as in HEAD.
Comment #13
Wim LeersAnd clean-up. The
MigrationPluginAlterer
class is obsolete as of #12.Interdiff explained:
This was making the
d7_metatag_field_instance:<entity type ID>:<bundle ID>
migration definitions depend on the corresponding<entity type ID>:<bundle ID>
migration.But … that does not actually make sense.
It makes sense for depending content entities like the
Redirect
content entity that thed7_path_redirect
migration does (which served as the inspiration for much of this code).But in this case, the metatag information is part of the
<entity type ID>:<bundle ID>
entities it is for, so these dependencies were wrong.See
which #12 added.
Comment #16
Wim LeersI cannot reproduce this failure locally 😬
Comment #17
DamienMcKennaThat's an unusual error, it might be dependent upon the version of MySQL being used.
I've started another test run using MySQL 5.5.
Comment #18
tim.plunketthttps://stackoverflow.com/a/41887524/614351
#567148: Use ONLY_FULL_GROUP_BY for MySQL
Comment #19
Wim LeersComment #20
DamienMcKennaOk, the tests are passing again, thank you Wim.
This is excellent work, thank you both.
What's next for this?
Comment #21
Wim LeersNothing AFAIK 😊
Comment #22
tim.plunkettI'd RTBC but I wrote the initial patch.
All of the subsequent changes by Wim are spot on, so +1 for this being ready to go.
Comment #23
DamienMcKennaExcellent, thank you both!
Comment #24
Wim LeersExciting! 🚀
Comment #26
DamienMcKennaCommitted. Thank you both!
Comment #28
bob.hinrichs CreditAttribution: bob.hinrichs commentedI originally posted complaining that this broke my migrations with no documentation I could find. I see this has changed migration quite a bit, it is better, and necessary, but potentially adds many migrations needed to migrate the site.