Problem/Motivation
Menu links in Drupal 6 are translated using i18n_menu submodule of the suite i18n, we need to migrate those respecting the language settings.
Proposed resolution
There's an element called langcode in the options array of the menu items: $item['options']['langcode'] and it's saved using i18nstrings in a key-value-language table.
Only title and description are stored with the i18nstrings module by using this tokens:
'menu:item:'. $mlid .':title'
'menu:item:'. $mlid .':description'
We probably need to have a plugin source that gets all this information from the {i18n_strings} table.
Original report by Ryan Weal
i18n menu (D6/D7 i18n contrib -> D8 menu config). This contrib module provided a setting where a site could have separate menus for each language and display only the desired one in a section. In cases where separate menus are used the menu links often do not have a language setting.
Postponed on #2178703: Migrate D6 menu links
Comment | File | Size | Author |
---|---|---|---|
#166 | 2225587-166.patch | 35.79 KB | alexpott |
#166 | 157-166.patch | 951 bytes | alexpott |
#157 | interdiff.txt | 1.85 KB | quietone |
#157 | 2225587-157.patch | 35.71 KB | quietone |
#151 | interdiff.txt | 593 bytes | quietone |
Comments
Comment #1
pcambraComment #2
phenaproximaComment #3
quietone CreditAttribution: quietone as a volunteer commentedComment #5
quietone CreditAttribution: quietone as a volunteer commentedA first attempt. This uses the EntityContentBase from the D6 i18n node issue.
Comment #7
Gábor HojtsyGenerally my feedback is that menus themselves have translatability settings as well. i18n supports different translation methodologies and menu items may have their own langcode (and be hidden/shown based on langcode) or be translated in-place like this. It is totally fine scope management to keep this issue for the in-object translation but it would be important to ensure only menus that had this setting take that data. Other menus may have had this setting before on and may have leftover translations in the DB that are not used. Looking at the code, one thing immediately stood out:
#2225775: Migrate Drupal 6 core node translation to Drupal 8 just introduced a very similar change to this method, so this may not be needed anymore.
Comment #8
Gábor Hojtsy@quietone: are you still working on this?
Comment #9
quietone CreditAttribution: quietone as a volunteer commentedI plan to resume working on the i18n issues this weekend.
Comment #11
quietone CreditAttribution: quietone as a volunteer commentedWell, that was a long weekend. Rerolled and moved to menu_link_content.
Comment #13
quietone CreditAttribution: quietone as a volunteer commentedAdded the new migration to MigrateUpgradeForm.
Comment #14
quietone CreditAttribution: quietone as a volunteer commentedReroll to use new source test class.
Comment #16
quietone CreditAttribution: quietone as a volunteer commentedEek, ignore #14, where I lost the changes and didn't notice.
Comment #18
quietone CreditAttribution: quietone as a volunteer commentedYicks. And now fixing the namespace error.
Comment #19
quietone CreditAttribution: quietone as a volunteer commentedNeeded a reroll because of #2669978: Migrate D7 Menu Links.
Comment #21
quietone CreditAttribution: quietone as a volunteer commentedMisplaced comma.
Comment #23
c_archer CreditAttribution: c_archer at Upbeat Productions commentedHi,
Has any progress been made with this, when importing menu link items the translation is not been selected for me.
Thanks,
Chris
Comment #24
quietone CreditAttribution: quietone as a volunteer commentedCorrected the dependencies in d6_i18n_menu_links.yml.
Comment #26
jofitz CreditAttribution: jofitz at ComputerMinds commentedAdd
language
to the dependencies in d6_i18n_menu_links.yml (and a couple of minor tweaks).Comment #27
quietone CreditAttribution: quietone as a volunteer commentedAssigning to myself for review.
Comment #28
quietone CreditAttribution: quietone as a volunteer commentedYes, language needs to be enabled and the other changes are good too. And I don't see any outstanding issues so probably RTBC, although I can't do that.
Comment #29
quietone CreditAttribution: quietone as a volunteer commentedComment #31
maxocub CreditAttribution: maxocub commentedI spent some time reviewing this issue in the last few days.
If I understand correctly, this is for the use case where you have, on your D6 site, a menu with language neutral links and have their titles & descriptions translated as strings. The menu is then always displayed with the titles & descriptions in the right language.
But what about the case where the menu items have their own langcodes and they are only displayed according to the current language? In this case, the links are duplicated for each language, so there's no need for translating their titles & descriptions as strings.
I tested this second use case manually and the migration throws some exceptions. I think we should try to support all use cases, if it is only possible.
Comment #32
Gábor Hojtsy@maxocub: well, the thing is Drupal 8 is not going to hide/show menu items based on language, so while that *data* may be entirely possible to migrate (per menu item language information), the behavior will not be there. Unlike the translation scenario. I think migrating the data for menu item language itself would also be useful but we should not make people expect it works the way it worked with i18n in Drupal 7. Also I think that may not fit in the scope of this one, but possibly in another issue, since its a different problem space.
Comment #33
Gábor HojtsyTaking for review.
Comment #34
Gábor HojtsySuperb, thanks for working on this.
What does this comment try to indicate? Not clear to me.
and => &&
Why do we need the locale module?
Should source be i18n?
One final thing that dawned on me here is that in #2225717: Add config translation support to migrations and implement for Drupal 6 user profile fields and the other issues we did not ensure that the fields themselves are configured to be translatable. We are not doing it here either. Maybe we need a followup for that and incorporate in our current patches? I mean we are migrating the translation but are users able to edit and use those translations?
Comment #35
quietone CreditAttribution: quietone as a volunteer commented1. The menu migration is actually in the system module, which makes it harder to find. The comment was added in #2589805: Add documentation on how to find the menu migrations.
2. Fixed
3. Without explicitly adding locale the Migration test fails with
I haven't looked further than that.
4. Fixed.
Like the i18n user profile issue, these migrations and tests should be moved to config_translation. I didn't do that here.
Comment #36
Gábor HojtsyHm, no, config translation module is a UI module and is not needed for config translation overrides to exist. One may use a different UI module or not expose this UI on the site and still config translations will function equally well. If we need to move this to a "language place", that would be language module then.
See #2225781-41: Migrate D6 i18n taxonomy vocabularies also, that may resolve the bug with locale. Remove both locale and config translation from the test, neither module would be needed to test this. Both are UI/integration modules and actual config translation API is in language module.
Comment #37
quietone CreditAttribution: quietone as a volunteer commented@Gábor Hojtsy, thanks.
Removed the loading of those two modules in the test.
Comment #38
Gábor HojtsyLooks good to me now for the scope it set out to do :)
Comment #39
alexpottI'm concerned about how this might scale as this is getting all the data at once. I also think this might be incompatible with the batching approach in \Drupal\migrate\Plugin\migrate\source\SqlBase() which this inherits from. Not sure.
Array syntax - this has now been standardised on the short syntax in all of core...
Comment #40
Pavan B S CreditAttribution: Pavan B S at Valuebound commentedMade changes as per the comment #39, Applying the patch, please review.
Comment #42
quietone CreditAttribution: quietone as a volunteer commented@Pavan B S, thanks for the updated patch. One small change to make sure that result is the results of the query.
Comment #43
quietone CreditAttribution: quietone as a volunteer commentedThe patch helps.
Comment #44
jofitz CreditAttribution: jofitz at ComputerMinds commentedSetting back to "Needs work" to address @alexpott's point in #39 about
fetchAll()
.It may be worth noting that a similar method is also used in
core/modules/migrate_drupal/src/Plugin/migrate/source/Variable.php
andmodules/migrate_drupal/src/Plugin/migrate/source/d6/i18nVariable.php
. Either we bite the bullet and accept this as is or whatever solution we come up with here should also be applied there.EDIT: It is also used in a similar manner in:
core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerFormDisplay.php
core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerViewMode.php
core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php
core/modules/field/src/Plugin/migrate/source/d7/ViewMode.php
core/modules/node/src/Plugin/migrate/source/d6/ViewMode.php
i.e.
Comment #45
quietone CreditAttribution: quietone as a volunteer commentedThis also needs renaming. The migrations be in the form basicmigration_variation. The same pattern should be used for the related files like migration plugins and tests. See #26 and #27
Comment #46
quietone CreditAttribution: quietone as a volunteer commentedLet's start with the rename, and adding a missing colon, before addressing any other issues.
Comment #47
quietone CreditAttribution: quietone as a volunteer commentedHere is a way to address the concerns #39. The source query makes rows with one property (title or description) per row. This is how the i18n_strings tables stores information, by property, so it makes the queries simpler. Then in prepareRow get the translation information for the other property as well as the untranslated values for each property.
There is also a process plugin that simply selects the translation of the untranslated version of the property. Could have done that in prepareRow but it seemed better to have the yml show that those values were being manipulated.
Comment #48
quietone CreditAttribution: quietone as a volunteer commentedThis causes menu links that have both a title and description translation to be migrated twice. Here is a way to prevent that.
Comment #49
quietone CreditAttribution: quietone as a volunteer commentedGábor Hojtsy asked about adding the language content settings to these i18n migration (#2225681: Migrate D6 i18n blocks translated strings) and it makes sense to do it here. I could be wrong.
Still I've added the migration of the language content settings for language, and the tests. And, the UI shows the custom menu links and the three fields are ticked as translatable.
Comment #51
quietone CreditAttribution: quietone as a volunteer commentedNot sure why MigrateUpgrade6Test is failing. But there is time to think about because postponing this until the source plugin test is fixed. #2862006: MigrateSourceTestBase returns false positives for most plugin tests.
Comment #52
heddnComment #53
jofitz CreditAttribution: jofitz at ComputerMinds commentedNo longer blocked.
Comment #54
quietone CreditAttribution: quietone as a volunteer commentedFixed the class name on MenuLinkTranslationTest.
Comment #56
quietone CreditAttribution: quietone as a volunteer commentedYes, there is another language_content_settings, so increment the entity count.
Comment #58
heddnBumping priority while triaging the queue in the weekly migrate meeting. Getting this done is blocking completion of d6 migration path.
Comment #59
quietone CreditAttribution: quietone as a volunteer commentedReroll.
Comment #61
quietone CreditAttribution: quietone as a volunteer commentedAnd a reminder that the migration needs to be renamed, See #2861383: Rename i18n migrations to _translation.
Comment #62
quietone CreditAttribution: quietone as a volunteer commentedAnd a nevermind to the reminder, this has already been renamed.
Comment #64
maxocub CreditAttribution: maxocub commentedI'll try to fix the test
Comment #65
maxocub CreditAttribution: maxocub commentedI think the test is failing because of this line. If I remove it, it passes, at least locally.
What is the purpose of this third_party_settings here?
Comment #66
quietone CreditAttribution: quietone as a volunteer commentedNeeded a reroll
Comment #67
quietone CreditAttribution: quietone as a volunteer commentedComment #69
quietone CreditAttribution: quietone as a volunteer commentedRemoved the process plugin a MenuLinkTranslation.php and moved the logic to the process pipeline. This was suggested by phenaproxima in #2909444: Migrate D6 i18n custom blocks (boxes).
Comment #70
quietone CreditAttribution: quietone as a volunteer commentedAnd the patch
Comment #72
quietone CreditAttribution: quietone as a volunteer commentedAdded source_module to source plugins. Two changes to d6_menu_links_translation.yml, change the name of the migration plugin to migration_lookup and the other to give it a valid input, 'd6_menu' instead of 'menu'.
Comment #73
quietone CreditAttribution: quietone as a volunteer commentedComment #75
quietone CreditAttribution: quietone as a volunteer commentedThe i18 submodules don't have an underscore in their name.
Comment #77
quietone CreditAttribution: quietone as a volunteer commentedChanged variable name property2 to other_property in the MenuLinkTranslation source plugin.
Removed 'third party settings' from the migration. As maxocub pointed out in #65 removing this allows the test to pass. I compared this migration to d6_language_content_menu_settings, which is probably where I started this patch way back when. Well, that migration uses a Drupal 6 variable from the i18n modules, language_content_type_. Reading the D6 code I only see that being used in reference to nodes so it isn't needed here and is safe to remove.
Comment #79
quietone CreditAttribution: quietone as a volunteer commentedOops, forgot to remove reference to third party settings in the test.
Comment #80
ao2 CreditAttribution: ao2 as a volunteer commentedTrying the patch from #79 I am getting this error:
The fact that there are 0 items to be processed makes sense because I have distinct per-language menus and not translated menus, but I still would not expect the error.
The solution for me is to just remove the migration since I don't need it, but I thought I'd report the issue anyway.
Comment #81
phenaproximaThanks for reporting this, @ao2! Can you post the exact steps you used (or close to it) to get this error? Anything we can do to improve this patch, and its test coverage, is hugely appreciated.
Comment #82
heddnHere's an improved error log/exception to help us know what is causing the issue. @ao2, can you re-test please?
Comment #84
ao2 CreditAttribution: ao2 as a volunteer commentedWith the new patch this message gets printed.
As I said I have two distinct menus, one per language, that means that the properties from both are in
i18n_strings
but they are not correlated, so the left joins end up giving results withlanguage
andtranslation
set toNULL
. I tried to execute the query fromcore/modules/menu_link_content/src/Plugin/migrate/source/d6/MenuLinkTranslation.php
manually and this seems to confirm the analysis.I can post the resulting rows if necessary, or execute another query if you suggest one.
Maybe it's enough to add a condition to filter rows with NULL
language
? Or a different type of join could be used.This quick and dirty change makes the error go away:
Ciao,
Antonio
Comment #85
jofitz CreditAttribution: jofitz at ComputerMinds commented@heddn Was this more like what you intended? Or have I got the wrong end of the stick (and should keep out of this!)?
Comment #86
heddn@Jo Fitzgerald that's more like it!
Comment #87
quietone CreditAttribution: quietone as a volunteer commentedThis is blocking #2918295: Move i18n query to a trait
Comment #88
ao2 CreditAttribution: ao2 as a volunteer commentedThe last patch from #85 fixes the error message but not the problem reported in #80.
As suggested in #84 a filter could be added or an
INNER JOIN
can be used here as well.Thanks,
Antonio
Comment #89
quietone CreditAttribution: quietone as a volunteer commentedThis needs to move to migrations
Plus need to respond to #88
Comment #90
jofitz CreditAttribution: jofitz at ComputerMinds commentedlookupDestinationIds()
was not runningunset()
on array elements with a NULL value (in this examplelanguage
) so added anarray_key_exists()
condition.@ao2 Would you mind retesting with this patch, please?
I'm wondering if the changes to Drupal\migrate\Plugin\migrate\id_map\Sql (and associated tests) should be moved to a follow-up issue - it's beyond the scope of this ticket.
Comment #92
jofitz CreditAttribution: jofitz at ComputerMinds commentedComment #93
phenaproximaLooks like this needs a reroll...
Comment #94
phenaproximaAlso, the last patch against 8.5.x appears to have failed testing. :(
Comment #95
jofitz CreditAttribution: jofitz at ComputerMinds commentedCan anyone enlighten me on the test failures - I don't understand.
Comment #97
jofitz CreditAttribution: jofitz at ComputerMinds commentedCorrect the test failures.
Comment #99
jofitz CreditAttribution: jofitz at ComputerMinds commentedCorrect the test failures.
Comment #100
maxocub CreditAttribution: maxocub commenteds/i18n_menu/i18nmenu
I don't see the 'type' used anywhere, I don't think we need it.
'name' is not the only field this plugin returns. We should document the other fields like status and/or language_alterable.
Could we not just return 'status' from the query? Is this prepareRow() really necessary?
I don't see the 'enabled' property used anywhere, do we really need it?
There should be a new line after the '-'.
Extra 'with'
s/i18n_strings/i18nstrings
This could be chained.
s/u18n/i18n
I removed the change in Sql and ran the MigrateSqlIdMapTest, and it still passed. I think we will need a failing patch to show that this change fix something. I would also agree that this could have it's own issue, but I don't want to slow this patch, so let's leave it here for now.
Comment #101
quietone CreditAttribution: quietone as a volunteer commented@maxocub, thanks for the review!
1 Fixed
2. I left 'type' since it is a condition on the query. I'd rather be sure that we only get the status of a module and not something else with the same name (yes, very very unlikely).
3. fields() updated
4. yes, just using status now
5, 6, 7, 8, 9, 10. Fixed
11. I did the same thing, removed the change in Sql.php and the test failed. I've made a fail patch and interdiff-101-fail.txt should show what I did.
Now, lets see if the patch passes tests.
Comment #103
maxocub CreditAttribution: maxocub commentedThanks @quietone for the failing patch, I don't know why it passes on my machine, but I think this failing patch shows that it works.
The code looks good now, except for an unused use statement in LanguageContentMenuSettings source plugin (Row is not used anymore).
But sadly, I'm still experiencing similar failures as @ao2 mentioned in #84.
The patch works very well if you have only one menu with items configured to be displayed for all languages and with their strings translated with the interface translation tool. But if like @ao2 you have one menu per language, or like what I tried, one menu with different items for each languages, then there's integrity constraint violattions:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'langcode' cannot be null: UPDATE @menu_link_content SET id=:db_update_placeholder_0, bundle=:db_update_placeholder_1, uuid=:db_update_placeholder_2, langcode=:db_update_placeholder_3 WHERE id = :db_condition_placeholder_0; Array ( [:db_update_placeholder_0] => 129 [:db_update_placeholder_1] => menu_link_content [:db_update_placeholder_2] => 832662fb-f294-4d29-97a1-8ad74eed3843 [:db_update_placeholder_3] => [:db_condition_placeholder_0] => 129 )
I think @ao2 is right about the inner join. The problem is that with his or my scenario, the strings are not in the locale_target table and the left join is getting untranslated menu items, and thus no langcode. We should definitely add tests for those cases. I think an easy way to reproduce this in a test would be to have an untranslated menu item, that is a menu item that is in the i18n_strings table but not in the locale_target table.
Comment #104
quietone CreditAttribution: quietone as a volunteer commentedHope to work on this this weekend.
Comment #105
quietone CreditAttribution: quietone as a volunteer commented@maxocub, thanks for the analysis, it makes more sense to me now.
I have added a translated link that does have an entry in i18n_strings but not in locales_target to the secondary links menu. The tests for translated menu links includes the new link. I also added tests to MigrateMenuLinkTest because it does, in fact, migrate these translated links. There is a fail patch too which uses the left join.
Comment #108
quietone CreditAttribution: quietone as a volunteer commentedUpdated the entity counts and extended the source plugin form MenuLink instead of DrupalSqlBase.
Comment #109
maxocub CreditAttribution: maxocub as a volunteer commentedThank you @quietone, I'm going to review & test this tomorrow at work, where I have a Drupal 6 installation.
Comment #110
phenaproximaThe patch looks good but TBH, I don't quite grok it...
The ID and label seem a bit mismatched.
Is this needed? Won't Migrate Drupal filter this source (and its migration) out if i18nmenu is not enabled in the source?
Comment #111
maxocub CreditAttribution: maxocub as a volunteer commented@phenaproxima is right, I don't think we need the LanguageContentMenuSettings source plugin. We could use the Empty source plugin and move the 'status' into a constant, and this migration won't be detected if i18nmenu is not enabled on the source site. So this is one source plugin and one test we can get rid of.
Also, there's a few coding standards messages:
Comment #112
maxocub CreditAttribution: maxocub as a volunteer commentedUnassigning
Comment #113
quietone CreditAttribution: quietone as a volunteer commentedHope to get to this on the weekend.
Comment #114
quietone CreditAttribution: quietone as a volunteer commentedHere are fixes for #110.1 and all of #111.
For #110.2, I tried maxocub's suggestion of using the empty source plugin instead. That results in the 'source_module' not found error. I've attached a fail patch for that.
Comment #116
quietone CreditAttribution: quietone as a volunteer commentedUnassigning
Comment #117
maxocub CreditAttribution: maxocub as a volunteer commentedThat's weird, the empty source plugin can't be use anymore? Isn't this a bug? The source_module is clearly provided. I'll take a look at this.
Comment #118
heddnI don't see any uses of
plugin: empty
in core right now. And it doesn't seem that we merge in any of the plugin config/options when we call the source plugin manager'sgetDefinition()
. So, this could be that we need to merge that in and we have us a legit feature/bug in the source_module checking logic.Comment #119
quietone CreditAttribution: quietone as a volunteer commentedWorking on a problem with the empty source plugin isn't in scope here, in my opinion. Maybe part of #2937045: source plugin source_module testing seems incomplete?
Also, are you sure that using the empty source plugin will not prevent the migration from being discovered as suggested in #111. The logic to ignore a plugin if the source database doesn't have the source_module enabled is in DrupalSqlBase::checkRequirements and that doesn't look like it is called when using the empty source plugin.
Comment #120
phenaproximaWe discussed this in the Migrate maintainer call and decided that, in the name of landing this damn patch, we can use the Embedded source plugin for now (which does define a source_module), rather than switch to the Empty source and block on #2937045: source plugin source_module testing seems incomplete. So let's do that; hopefully it works and we can get this in.
Comment #121
quietone CreditAttribution: quietone as a volunteer commentedOh fudge, I didn't document that I tried the embedded source plugin. That is still discovered even when i18n menu is not enabled on the source.
Comment #122
heddnOne idea is t to create a @internal Final subclass of embedded w/ annotation of source_module 'i18n_menu'.
Comment #123
heddnHere's why we need to extend DrupalSqlBase! We need it so we can check if a module is enabled on the source d6/d7 database. There is no easy way to do that without extending that class. Because the info we need from d6 is if 'i18n_menu' is enabled. And if it is, then it will get discovered and we'll be happy again.
Solved.
Comment #124
phenaproximaThis is shaping up wonderfully but I think we still need some tweaking, sadly.
This was jarring when I first looked at it, but it made sense once I realized that menu_link_content is a content entity type without any bundle support (although it does have a 'bundle' key, for some reason). We should add a comment here explaining that, so that others don't stumble upon this and have a WTF moment.
This looks like the wrong constant. Shouldn't it be 'constants/langcode'? If so, the tests apparently didn't catch this, so we should probably add an assertion or two somewhere. :)
Although, looking in the ContentLanguageSettings entity, it appears that the default_langcode is set to site_default anyway. So maybe we can remove this line completely.
I think we could/should make this a generic plugin (for both Drupal 6 and Drupal 7) which returns the system data of a module/theme (or several modules/themes) in the source database, rather than hard-coding i81nmenu and the name/type.
We could call this plugin something like LegacyExtension, and it could key by name, type, and schema version.
This should be assertInstanceOf().
Let's use LanguageInterface::LANGCODE_SITE_DEFAULT instead of hardcoding 'site_default'.
Can we add a comment explaining that this will only be true if i18nmenu is enabled? And can we add a test that proves it's false if i18nmenu is disabled in the source DB? (No need to alter the fixture; just run a query against the source database before executing the migration.)
Do we want to skip the row if migration_lookup returns no result?
Do we want to bail out if the lookup fails?
I'm not sure we should be enforcing truncation here. The migration should probably do it in the process pipeline, if possible.
This should probably be a helper method which works on the query object. We could call it from here and in query().
We need to handle the case where the query returns no result. Maybe just throw a MigrateException or something?
Aren't these called title_translated and title_untranslated? (Plus description_translated and description_untranslated, respectively.)
Let's add an assertInstanceOf() to check that $menu_link is, in fact, an instance of MenuLinkContent. That way, if it isn't, the test will be able to fail gracefully instead of choking on a fatal error.
Should be assertTrue() and assertFalse(), respectively.
We should assert that $menu_link is an instance of MenuLinkContent (assertInstanceOf()) before calling methods on it.
What is this for?
Should use assertTrue().
Should assert that $menu_link is an instance of MenuLinkContent.
Same here.
Need to assert that $menu_link is an instance of MenuLinkContent.
Should use assertTrue() and assertFalse() here.
assertInstanceOf() missing :)
Should use assertTrue() and assertFalse().
Why was this change made? Surely isset() should have both bases covered?
NICE! Better error reporting is such a wonderful thing. IMHO, this should be its own exception (which would allow intrepid debuggers to inspect the extra source items, rather than just a dump of them), but that can be done in a minor follow-up issue.
Comment #125
quietone CreditAttribution: quietone as a volunteer commentedStill plenty to do.
1. Comment added
2. fixed the constant. Not sure we should remove this process from the pipeline.
3. Good idea. New plugin, LegacyExtension added in system module. Should it return all possible fields or just the 4 given in the plugin?
4. Fixed
5. Fixed.
6. Comment added but in the migration yml file instead of the test. I reckon people are more likely to look at the migration than the test.
7-11. Todo
12-15. Fixed.
16. I have no idea! removed.
17-23. Fixed
24. todo
25. Credit to heddn on that. #82
Comment #127
quietone CreditAttribution: quietone as a volunteer commentedMany of the test failures are not related. Just moving on with the other points in #124.
7. Fixed. Skip added
8. Removed this, not sure why it was added. Easy to add back if needed.
9. Instead of doing the truncation here, this now calls parent:prepareRow, which does the truncation.
10. I don't see how this can be added to the query() method.
11. If the query for the 'other property' returns no result it is still a valid case. It just mean that that 'other property' does not have a translation.
24. The isset keeps the addition of a condition on NULL in the query. It the field is NULL, nothing should be added to the query.
Comment #129
quietone CreditAttribution: quietone as a volunteer commentedAdd 'Configuration' tag to the d6_language_content_menu_settings migration.
Comment #131
quietone CreditAttribution: quietone as a volunteer commentedThe renaming of properties in the MenuLinkTranslation source plugin required changes to the source plugin test. Changed the source_module in the plugin from i18nmenu instead of i18nstrings. Removed unnecessary property from the d6_menu_links_translation.yml.
Comment #133
quietone CreditAttribution: quietone as a volunteer commentedCurious that that error wasn't in the previous test. Also removed an unused use statement.
Comment #135
quietone CreditAttribution: quietone as a volunteer commentedSilly mistake tagged it Content when it should be Configuration
Comment #136
quietone CreditAttribution: quietone as a volunteer commentedThe points raised in #124 were fixed and/or commented on in #126 and #127. Note that no change was made for #124.10 because the query in prepareRow isn't in query() because data from two rows from i18n and locales each are needed, one for property A and one for property B. I could only get the working with a union, which failed later since it wasn't joinable. It was also a bit complicated to read. That is why there are two similar queries.
Comment #137
quietone CreditAttribution: quietone as a volunteer commentedActually, originally there wasn't an extra query in prepareRow(). That version was kicked back by alexpott in #39 for scalability. That is why one property is retrieved in query() and the other in prepareRow().
Comment #138
phenaproximaThis is really close. I could find very few objections, and nothing earth-shaking.
Modules and themes cannot share names, so I don't think legacy_extension needs to be able to filter by type.
Should this also key by mlid?
About this, @quietone said:
Given this, I still don't think we need the array_key_exists() check. Just doing
isset($source_id_values[$field_name])
oughta do the trick.Let's just select all fields in system. No need for a subset. And let's add a prepareRow() implementation to unserialize the saved extension info.
I don't think we should filter by type or schema version. Since extensions can't have name collisions, filtering by type is pointless. And schema_version is an integer, so it's not a very useful filtering criterion unless we also support comparison operators like !=, >, etc. Which we can add in a follow-up if needed.
'name' is useful, but IMHO it should be an array (or a string that is cast to an array).
This will need to be changed.
I'd say we only need to key by name.
Comment #139
quietone CreditAttribution: quietone as a volunteer commented1. Fixed
2. parent::getIds() returns mlid, so it is included.
3. I don't seem to be explaining this well. I have made the change suggested but in a fail patch.
4. Fixed
5. Fixed
6. Fixed
7. Fixed
Comment #141
phenaproximaHeh, it tried to test the interdiff. :) Back to NR.
Comment #143
phenaproximaI think this looks legit. Raise your seat backs and lock your tray tables in preparation for landing.
Comment #145
maxocub CreditAttribution: maxocub as a volunteer commentedThis needs a re-roll.
Comment #146
maxocub CreditAttribution: maxocub as a volunteer commentedHere's a re-roll.
Comment #148
quietone CreditAttribution: quietone as a volunteer commentedSo the error is:
Using the "Legacy" prefix to mark all tests of a class as legacy is deprecated since version 3.3 and will be removed in 4.0. Use the "@group legacy" notation instead to add the test to the legacy group.
which is really unfortunate. This is not a legacy test, it is a test of a source plugin accessing the system table of the Drupal 6 or Drupal 7 system.
Comment #149
quietone CreditAttribution: quietone as a volunteer commentedRenamed LegacyExtension to just Extension, the source plugin from "legacy_extension" to "extension".
Comment #151
quietone CreditAttribution: quietone as a volunteer commentedTest class renamed incorrectly.
Comment #152
maxocub CreditAttribution: maxocub as a volunteer commentedGreat, back to RTBC.
Comment #154
quietone CreditAttribution: quietone as a volunteer commentedIt was a testbot hiccup and I reran the tests. All green again.
Comment #155
alexpottAs far as I can see this is going to return 2 rows for every menu link one for title and one for description. Doesn't this mean we'll do unnecessary processing?
And yeah it is a shame we have to use prepareRow to do something we advise people against.
As far as I can see we have no test case where either the title or description is not translated. In our test cases they always appear to be both translated. Is that always the case - the docs imply its not.
Comment #156
quietone CreditAttribution: quietone as a volunteer commented155.1 Yes, there is extra processing. This was pointed out in #48 where adding a skip process prevented the double processing. This was removed in #127 based on comment #124.8, which appears to be a mistake on my part. Setting to NW for that
155.2 No. Menu link 139 has a Zulu description but not a Zulu title. Menu link 140 has a French title and and no description translations. I see test for these cases in MigrateMenuLinkTranslationTest
Comment #157
quietone CreditAttribution: quietone as a volunteer commentedAdded a test in prepareRow to determine if this row has already been migrated and, if so, to skip this row. That will avoid processing the duplicate rows. Moved things a bit in prepareRow so that test is done as early as possible.
If this passes tests then both points in #155 are addressed and this will be ready for review.
Comment #158
maxocub CreditAttribution: maxocub as a volunteer commentedI think #155 has been addressed with satisfaction, let's try to RTBC this again.
Comment #159
alexpottI'm not a huge fan of adding queries in
::prepareRow()
I think it goes against good practices especially when we are querying the same tables as in::query()
but it is tricky to see how to do this differently - to many axes - language and translated property.Credited people who reviewed and influenced the patch.
Comment #160
alexpottCommitted and pushed 66480d7f40 to 8.6.x and 45fcc489b4 to 8.5.x. Thanks!
Backported to 8.5.x as this is a migration and migrate_drupal is still in beta.
Comment #164
alexpottUnfortunately this broke postgres.
Comment #165
alexpottIf you run
Drupal\Tests\menu_link_content\Kernel\Migrate\d6\MigrateMenuLinkTranslationTest
on postgres you seeComment #166
alexpottPatch attached fixes PostgreSQL and doesn't break SQLite and Mysql.
Comment #168
heddnAssuming this comes back green, this is good to go. The comment explains it well and we have good test coverage.
Comment #169
alexpottSecond time lucky.
Committed and pushed b930c804e1 to 8.6.x and 56fd2e5a79 to 8.5.x. Thanks!
Comment #172
quietone CreditAttribution: quietone as a volunteer commentedI am pleased this is finally in! However, I woke up and realized that a manual test was not done with a source site without translations and content_translations not installed on the destination. It may be that the migration should be in content_translation just like d6_taxonomy_term_translation.yml
#2920598: Move d6_taxonomy_term_translation and test to content_translation
Comment #174
heddn@quietone did we ever open a follow-up for this from #172?
Comment #175
quietone CreditAttribution: quietone as a volunteer commented@heddn, it was fixed in #2960013: i18n menu links translation in wrong directory.