Problem/Motivation
The d7_taxonomy_term_translation migration plugin skips every row where i18n_mode is 1, 0, or is empty.
If the TermTranslation migrate source plugin excluded these rows, we would get back the appropriate source record number – and that would increase DX a lot imho.
Proposed resolution
Improve source query to only get that should be migrated, where i18n_mode is not 0 or 1.
Add source plugin test source/d7/TermTranslationTest.php
Remaining tasks
Review
Commit
User interface changes
N/A
API changes
Data model changes
N/A
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | 3187616-18.patch | 10.99 KB | quietone |
| #18 | interdiff-9-18.txt | 2.11 KB | quietone |
| #18 | 3187616-18.patch | 10.99 KB | quietone |
| #18 | interdiff-9-18.txt | 2.11 KB | quietone |
| #9 | 3187616-9.patch | 10.65 KB | quietone |
Comments
Comment #2
huzookaComment #3
quietone commentedThen shall we remove the skip from the migration?
No interdiff because the change is small as is the whole patch.
Comment #4
wim leersThis looks like a great simplification and hardening at the same time! 🥳
But as a relative outsider, both hunks (the one added by @huzooka and @quietone) are impossible to understand 🙈😅
Let's document why
0or1.Refer to the constants at https://git.drupalcode.org/project/i18n/-/blob/7.x-1.x/i18n.module#L15.
@quietone's comment at #3035392-24: Migrate vocabulary translations and taxonomy term references for Drupal 7 node translations also talks about this.
Comment #5
wim leersComment #6
wim leersSibling issue: #3187474: Improve source record count of translation migrate source plugins which use the "i18n_string" table.
Comment #7
quietone commentedUpdated comment as per #5.
Comment #8
wim leersThank you!
Wanted to RTBC this, but channeling @alexpott, I think we need to add test coverage for this in
\Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source\d7\TermEntityTranslationTest😅Comment #9
quietone commentedAnd you are doing a good job of channeling him!
Turns out there wasn't an existing test for this source plugin, so I added it. I don't know how that happened and I haven't researched it (and don't plan too). The test file you referenced, TermEntityTranslationTest, is for the TermEntityTranslation migration.
Comment #10
wim leersWoah, thanks for the super fast turnaround! I think @huzooka is better positioned to review this than I am 🤓
Comment #11
quietone commentedChanging to a bug. The query is incorrect and the test is missing.
Comment #12
quietone commentedComment #14
quietone commentedRetesting with 9.3.x.
Comment #15
quietone commentedTagging for Drupal South. This is for someone who has worked with migrations.
Wim Leers already thinks this can be RTBC but recommends another set of eyes on the work.
Comment #16
quietone commentedFixing the tag.
Comment #17
danflanagan8Now that it's classified as a bug, we need to show that the new test fails without the fix. I ran the new test locally without the other changes and got a wonderful failure:
Failed asserting that actual size 7 matches expected size 4.That's exactly what the issue is about, so that's good news.I have a question about this though.
I just want to confirm that I understand this condition. If the 'i18n_mode' field does not exist, then we're not translating terms. Therefore we want the query to return zero rows. To do that, we put on a condition that will never be met, since there will never be a term with a tid of zero.
Is that right? Could there maybe be a comment added to clarify that?
Or better yet, if I'm understanding the purpose of that condition, it looks like we could use
ConditionInterface::alwaysFalse()instead. But I may be misunderstanding things!Comment #18
quietone commented@danflanagan8, thank you for the review.
Yes, you are understanding the query correctly. I have changed to using alwaysFalse, which I think is much clearer. I have also added an sentence to the comment at the start of the if block to help explain what is happening. And I have added a test for the situation where there is not an i18n_node column in the taxonomy_vocabulary table.
Comment #19
danflanagan8@quietone, I like the new test case! And thanks for making to other changes to make things clearer.
Comment #20
wim leersWoah, very nice indeed, @quietone!
Comment #21
alexpottCommitted and pushed 4bc7dbb8f9 to 9.3.x and 88bb7758ba to 9.2.x. Thanks!