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.
Currently the migration process plugin accepts any string or array of strings for it's migration value.
This doesn't cause an error, just makes it hard to debug why your migration isn't working integrating if you mis-spell the migration (or have the migrations in the wrong order etc).
So I'm not sure really if this is a bug per se.
Comment | File | Size | Author |
---|---|---|---|
#44 | 2865247-44.patch | 14.54 KB | maxocub |
#44 | interdiff-2865247-42-44.txt | 3.17 KB | maxocub |
Comments
Comment #2
NickDickinsonWildeHere's a very simple patch to check. It won't catch all cases - it is simplistic - but should catch most normal use cases. Could use
count($migrations) != count($migration_ids)
instead I suppose.Also moved the existing inline @var comment to the right spot; not exactly in scope but pretty much within the touched code.
Comment #3
NickDickinsonWildeComment #5
NickDickinsonWildegerumble... pins reminder to self to make sure to include the use statement(s) on all patches.
Comment #8
anpolimusComment #10
heddnLet's add a test for this. Adding a phpunit test for this seems really fairly trivial, so tagging.
Comment #11
heddnComment #12
rakesh.gectcrWe need to do a reroll for this
Comment #13
rakesh.gectcrrerolled with 8.6.x
Is it the righ direction?
Comment #14
heddnStill needs tests.
Nit: whitespace.
sprintf('The (%s) plugin failed because no migrations from (%s) were available.', $this->getPluginId(), implode(', ', $migration_ids))
Comment #15
jofitz CreditAttribution: jofitz at ComputerMinds commentedAddressed corrections and added tests.
Comment #17
heddnThe wording looks funny now that I see it concretely. The following seems to work better in my book:
The (migration_lookup) plugin failed because no valid migrations were found. Invalid migrations include: (invalid_migration).
The (migration_lookup) plugin failed because no valid migrations were found. Invalid migrations include: (d7nodepage, d7nodeblog).
Comment #18
jofitz CreditAttribution: jofitz at ComputerMinds commentedRe-worded the exception as suggested.
Added a couple more test scenarios.
Comment #19
heddnLooking good.
Comment #20
alexpottif (empty($migrations)) {
but also maybe this is not the right condition.Like the helpful exception but the wording is odd and the use of brackets. How about:
The '%s' plugin failed because no migrations with the following ID(s) exist: %s.
Also do we always expect all the $migration_ids to load.
Ie. should we be testing
count($migration_ids) === count($migrations)
?Or maybe...
Comment #21
jofitz CreditAttribution: jofitz at ComputerMinds commentedAlso added another test for when some, but not all migrations are valid.
Comment #22
alexpottWe now know the missing migration(s) - I think we should take the opportunity to use that info in the error since it's helpful.
Comment #23
jofitz CreditAttribution: jofitz at ComputerMinds commented@alexpott It seems the assumption that
count($migration_ids) === count($migrations)
is not correct - it does not take into account derivatives (I'm not sure whether that's the technical term), i.e.d7_node
returnsd7_node:article
,d7_node:blog
, etc.I can see no better solution than
empty($migrations)
(without adding a lot of complexity).I've gone back to the patch in #18 and worked off that, ignoring #21.
Comment #24
maxocub CreditAttribution: maxocub as a volunteer commentedIt would be nice to expand this docblock with a one line summary and details about the function's parameters.
Comment #25
jofitz CreditAttribution: jofitz at ComputerMinds commentedExpanded the docblock.
Comment #27
maxocub CreditAttribution: maxocub as a volunteer commented@Jo Fitzgerald: Thanks!
Comment #30
alexpottCommitted and pushed b208b07712 to 8.6.x and 3c812149b7 to 8.5.x. Thanks!
Comment #31
quietone CreditAttribution: quietone as a volunteer commentedThis change breaks the d6_url_alias and d7_url_alias mgrations when content_translation is not enabled. I found this because it broke HEAD on commerce_migrate.
Here is the relevant snippet form d6_url_alias.yml
So, when d6_url_alias or d7_url_alias (they have the same process in the pipeline) runs and d6_node_translation (or d7_node_translation) isn't found an exception is thrown and the row is not saved. But it should be saved. Before this change migration_lookup would return NULL and the row would save resulting in a successful migration. As it is now, content_translation must be enabled for the URL alias migrations to be successful.
If there is agreement on that can this be reverted?
Comment #32
quietone CreditAttribution: quietone as a volunteer commentedChanging priority since this breaks migrations without content_translation enabled. Tempted to mark critical because of the data loss in the migration process.
Comment #33
benjy CreditAttribution: benjy at Unearthed commentedWhy does the path migration depend on a content translation migration? That seems wrong, just shown by the fact MigrationLookup now throws an error. Shouldn't node or content_translation edit the migration dynamically to add the "node_translation" parts to the url alias migrations?
Comment #36
alexpottSo neat we discovered two things here. We seem not to have a test for the url alias migrtations without content_translation in core and that there seems to be a valid case when you have no valid migrations to look up.
I've reverted the issue so we can address these things.
Comment #37
quietone CreditAttribution: quietone as a volunteer commented@alexpott, thanks.
It look like the addition of d6_node_translation to the migration was added in #2827644: Fix path alias migration of translated nodes [D6].
Comment #39
maxocub CreditAttribution: maxocub as a volunteer commentedI implemented @benji's suggestion from #33 and I moved all translation related code over to Content Translation.
I also modified the URL alias tests so that the first test is run without Content Translation enabled. I included a fail patch to show the bug.
Now, having all the files ready to upload, I'm wondering if I should have done this in a different issue. I'll upload them anyway so we can see if the test are green. If anyone think it should be done in a new issue, I'll be happy to do so.
Comment #41
heddnWe cannot be sure we know the ID and it won't change. We'll need to use the source plugin's class to check this. Can we add this in a deriver? I would much rather see this there than in a plugin alter. Much cleaner code.
Can we provide a config option to migration_lookup that will let us disable the exception throwing? Defaults to throw.
Comment #42
maxocub CreditAttribution: maxocub as a volunteer commentedThanks for the review @heddn!
UrlAliasDeriver
. I hesitated between adding two derivers, one for D6 and one for D7, or only one deriver with an if statement. I chose the later.validate_migration
configuration to themigration_lookup
plugin, defaulting to TRUE.Comment #43
heddnFor readability, let's state this as, "set validate_migration to FALSE."
I think this is the only thing different, so can we move that part into the version conditional logic and move the rest outside so as to reduce duplicate code?
I'm also a little torn about defaulting to always throwing an exception. I understand it will help, but it could easily be a distraction. And in a way, if we want to stretch things a little, we are breaking BC. Because previously migrations that were built wouldn't throw that exception. What if we add validate_migration => TRUE to all migration_lookups in core yamls. Then all new migrations will get this feature. But ones that have been running for quite some time will not suddenly start failing. We still want to default to TRUE on any new generated migrations, but not on things have already been generated and someone is currently using.
Comment #44
maxocub CreditAttribution: maxocub as a volunteer commentedI agree that this kinda break BC because an Exception might be thrown where it wasn't before. But I don't understand how we can default to TRUE for new migrations but not for existing (contrib or custom) migrations.
Comment #45
heddnWe can sorta do that for new if we assume that folks are copy/pasting the yaml files or using some type of config system with migrate_plus config entities. In those cases, the yml files they use are copies. If we just change all of core's templates and all uses of derivers, etc, to set validate_migration = TRUE, then we sorta get this for new migrations and not for existing. If we assume that existing copies wouldn't have the validate_migration in their yaml files because they copied them before we added it everywhere.
Comment #46
maxocub CreditAttribution: maxocub as a volunteer commentedDiscussed in the Migrate maintainer meeting. First, we should move the url_alias stuff to a new issue. Second, let's add this functionality with a default to FALSE, so we don't break BC, and open a follow-up to figure out how to implement it (adding the config to all migration_lookup plugins?).
Comment #53
quietone CreditAttribution: quietone at PreviousNext commentedThis was committed to Drupal 8.5.x and re-opened because it the url_alias migrations were failing if content_translation was not enabled. That was a problem with a change of behavior introduced here and was fixed in #3086952: Migration Lookup should catch PluginNotFoundException exceptions and ignore them. and a test without content_translation was added. The following work here was fixing the problem by adding a lot more code by using a deriver.
Therefor, restoring the issue meta data to the time this was committed.
Thanks.