Migrate variable language_default to system.site config.
This was originally part of #2225775: Migrate Drupal 6 core node translation to Drupal 8. It is moved here to reduce the scope of that issue. And it conforms to the existing practice of a separate issue for each D6 or D7 variable to config migration.
Credit should go to phenaproxima.
Comment | File | Size | Author |
---|---|---|---|
#50 | interdiff-44-50.txt | 7.73 KB | maxocub |
#50 | 2657978-50.patch | 7.75 KB | maxocub |
#44 | interdiff-32-44.txt | 12.82 KB | maxocub |
#44 | 2657978-44.patch | 7.22 KB | maxocub |
#32 | interdiff-27-32.txt | 4.11 KB | maxocub |
Comments
Comment #2
quietone CreditAttribution: quietone as a volunteer commentedAnd the patch.
Comment #3
quietone CreditAttribution: quietone as a volunteer commentedLooks good.
Committers: All credit to phenaproxima.
Comment #4
alexpottHmmm... but this is the default value - how can we be sure that the migration has worked? Also I have no idea how the migration knows to put the value in the
default_langcode
config key.Comment #5
quietone CreditAttribution: quietone as a volunteer commentedThe migration template now has the correct input to the extract plugin. And the test now checks for French instead of English.
Comment #6
Gábor HojtsyComment #7
quietone CreditAttribution: quietone as a volunteer commentedComment #8
Kristen PolThanks for the patch! Some feedback:
Should there be comments here?
This comment isn't very clear to me. Perhaps change to something like:
The test system defaults to English, so update the default language variable to French so it can be checked.
Though even what I wrote isn't that clear to me. :/
Comment #9
quietone CreditAttribution: quietone as a volunteer commented1. Yes, fixed.
2. Is this better?
Thx
Comment #10
Kristen PolYes, that is better but needs to be wrapped to fit in 80 characters. Thanks!
Comment #11
quietone CreditAttribution: quietone as a volunteer commentedSorry, IDE had wrong margin (and I didn't notice).
Comment #12
Kristen PolLooks good. Thanks! What's the best way to test this?
Comment #13
quietone CreditAttribution: quietone as a volunteer commentedThx. To test this will work,
On a D6 source site,
On a D8 source site,
Run the migration. Upgrading from Drupal 6 or 7 to Drupal 8 has all the details.
When the migration is finished, go to /admin/config/regional/language. The default language on D8 will now match the default language set on the D6 source site.
On the topic of testing, migration has an existing issue to Ensure migration tests are meaningful.
Hope that helps.
Comment #16
Gábor HojtsyLooks great to me :) No problems found on a code review, test seems complete.
Comment #17
alexpottSo what guarantees that the default language actually exists on the target site? I.e. as a configurable language.
Comment #18
Gábor Hojtsy@alexpott: I don't believe we checked that either in #2225775: Migrate Drupal 6 core node translation to Drupal 8 for each node. It can certainly be checked, but then it needs its own variable plugin extension class I guess.
Comment #19
maxocub CreditAttribution: maxocub commentedI'm not sure I understand why we should check if the language exists. There seems to be already a migration for the languages, so if on the D6 site, French for example was the default language, then French would be migrated and then made the default language.
Since the languages are migrated, I don't understand why we should look if it exists.
This is the first time I spend some time on a migrate issue, so maybe there something that I don't see.
I tested the patch by following @quietone comment #13 (which doesn't ask to add the language on the D8 site before migrating) and the D6 default language is added to the D8 site and marked as default as expected.
Comment #20
maxocub CreditAttribution: maxocub commentedIt also seems to work if the default language on D6 was a custom language, not in the language list. The custom language is added to the D8 site and marked as default.
Comment #21
Gábor Hojtsy@maxocub: I think it should be checked/tested because the default language on the D6 site may not exist on that D6 site. It may cause more problems in D8 although it was probably not a simple problem in D6 either. Let's see how we can test it:
So if you are saying French gets created even if not in the language list, we can add a line of test here to ensure the config has French among the languages too, eg. Language::load('fr') returns a language.
(If that is because the source data dump had French, we should pick a language other than French here to test with or better yet test first with French and then with some other language that is not in the database dump second -- or in another test method).
@maxocub: I think this is something you can do it should not require migrate know-how only tests need to be modified for now :)
Comment #22
maxocub CreditAttribution: maxocub commentedHow could a default language not exists on a D6 site? By modifying the DB directly, or with drush?
Comment #23
maxocub CreditAttribution: maxocub commentedI just tested it manually by modifying the D6 DB. The D8 configuration for the default language is changed to the D6 one (I checked it at admin/config/development/configuration/single/export), but since the language itself doesn't exists, the interface (at admin/config/regional/language) shows English as default.
Now, I'll add a method to the test class.
Comment #24
maxocub CreditAttribution: maxocub commentedHere's an updated test.
It will fail since it tests the migration with a non-existent language.
I had to trigger the language migration otherwise even the French didn't exist.
Why is i18n-migrate in the tags list? Does this issue have something to do with the i18n module?
Comment #26
maxocub CreditAttribution: maxocub commentedThis is to get rid of the second 'unrelated' fail.
Comment #27
maxocub CreditAttribution: maxocub commentedIt's late, can't put things in alphabetical order...
Comment #30
Gábor Hojtsy@maxocub: sounds like that exposes the problem that @alexpott was aiming at. Not sure what migrate should do in this case though. The language may not exist due to the language migration not running earlier as you noted. @alexpott what do you think migrate should do here?
Comment #31
alexpottNice work reproducing the issue @maxocub! I think this migration should depend on the language migration and if the language still doesn't exist it needs to report an error and not migrate.
Comment #32
maxocub CreditAttribution: maxocub commentedHere's what I came up with so far. Any comments?
Now I've got to find out how to update the test to check if the migration fails if the language doesn't exists.
Comment #34
maxocub CreditAttribution: maxocub commentedComment #35
maxocub CreditAttribution: maxocub commentedComment #36
Gábor Hojtsy@maxocub: I also brought this up at the migrate meeting today so hopefully it will get some reviews that way too.
Comment #37
quietone CreditAttribution: quietone as a volunteer commented@maxocub, thx for moving this along. I'm a novice at reviews, but here goes.
Not needed
The constructor can be removed.
Should we really be looking at the destination in a source plugin? Ideally, the source just gets the data. Making a decision based on the destination site configuration probably should be done in a destination plugin. There certainly aren't exceptions in other source plugins. And s/exists/exist.
Can someone else comment on this?
Can be removed.
Namespace for the tests should be Drupal\Tests\language\Kernel\Migrate\d6;
If this is the same for d6 and d7, then OK. Otherwise it needs to be in a subdir. If for both, then a test for D7 needs to be added.
And a final note that the docs,https://www.drupal.org/docs/8/upgrade/preparing-an-upgrade, should be updated to state that languages need to be installed on the D8 site before migrating.
Comment #38
Gábor Hojtsy@quietone: re your final note, this in the patch should already ensure languages happen earlier, so no docs updates required?
Comment #39
Gábor HojtsyBTW good point on the source checking the destination going over the wall of separation of concerns. Looks like the general direction is that the destination plugin should be extended from the config plugin, while the source plugin remains as-is.
Comment #40
quietone CreditAttribution: quietone as a volunteer commented@Gábor Hojtsy, I thought it was said at the meeting that the docs should be updated. Though, I could have been coughing at the time and got it wrong. But either way, wouldn't it be helpful to explicitly say what to do about languages in the 'Preparing for an upgrade' docs?
Comment #41
Gábor Hojtsy@quietone: well, we could explicitly say people don't need to do anything about it, because the migration takes care of that, but is that something we document? "Don't do anything with your languages because they will get migrated"?
Comment #42
maxocub CreditAttribution: maxocub commentedThe languages do get migrated. What we're doing here is checking for an edge case where a D6 default language does not exist on the D6 site, so then it does not get migrated. Maybe we can say something about that? Ask that people verify that their D6 default language exists on their source site?
Thanks @quietone for you review! I'll move the verification to a destination plugin.
And about your sixth point, yes, it does look like it's the same for D7, so I guess I should also change the file d6_default_language.yml to default_language.yml
Comment #43
maxocub CreditAttribution: maxocub commentedThrowing a MigrateException in a destination plugin doesn't seem to mark the migration as failed. The status message tells me that all migrations were succesfull while in the log I see the thrown exception.
Can someone tell me why it worked in the source plugin but not in the destination plugin?
Comment #44
maxocub CreditAttribution: maxocub commented@quietone: I used a destination plugin as you suggested and I made the changes to cover D7 too.
I have two questions about the tests:
1) Since the two tests are almost identical, I thought about making a new class to reduce code duplication, but since they each extend their own base class for D6 and D7, I haven't found how we could do that. So is it OK to leave it as is?
2) I haven't found how we could test that the migration fails if the language doesn't exist. Is there another test in core that does that?
Comment #46
quietone CreditAttribution: quietone as a volunteer commentedAh, now I see what was niggling me. Of the current migrations dealing with languages or translations this is the only one that checks that the source language exists on the destination site. Should the other migrations that deal with translations, such as d6_i18n_system_maintenance, also verify that the language exists on the destination?
Comment #47
Gábor Hojtsy@quietone: well, that would be out of scope for this issue. I also posted that feedback to @alexpott in #18 that we don't check the existence of the language used in node translation migrations either. That said, a nonexistent language there may be a smaller problem compared to here due to the default language being on the container.
Comment #48
quietone CreditAttribution: quietone as a volunteer commented@Gábor Hojtsy, sorry, I see that now.
How will work for both cases, when the language exists on the destination and when it doesn't? When the language doesn't exist, $default_language would be NULL and the default_language in the configuration would still be the same as before the migration.
Comment #49
maxocub CreditAttribution: maxocub commented@quietone: The test needs to be updated. It needs to check if the migration fails if the language does not exists on the destination. That's where I'm at, and I haven't found yet how to test that. I tried with $this->startCollectingMessages(), but the array $this->migrateMessages is always empty. I'm working on it.
Comment #50
maxocub CreditAttribution: maxocub commentedHere's an updated test.
I used the migration messages to check if there's an error due to the non-existing language and I use a trait to avoid code duplication between the D6 and D7 tests. I don't know if there's a better way to accomplish that.
Comment #52
maxocub CreditAttribution: maxocub commentedComment #53
Gábor HojtsyThis looks to be resolving all the concerns @alexpott had and nicely tests the situation on both D6 and D7 with both an existing and missing language. Looks fine to me :)
Comment #54
xjmAs a non-disruptive addition to an alpha experimental module, this issue is rc eligible per: https://www.drupal.org/core/d8-allowed-changes#rc
Comment #56
Gábor HojtsyMarked #2751223: D6 & D7 users are migrated into D8 with incorrect langcode postponed on this one since that needs this for error resolution.
Comment #61
catchVery minor but these should be one-line. I'm going to change on commit to 'Tests language_default migration with an existing language' (and etc.)
Failed to spot the 'credit should go to phenaproxima' note before committing, but added issue credit...
Comment #62
maxocub CreditAttribution: maxocub commentedThanks!
Comment #64
Gábor HojtsyRemoving from sprint, thanks all again!
Comment #65
maxocub CreditAttribution: maxocub as a volunteer and commented