The D7 language types needs to be migrated to D8. In D8, the language.types configuration by default looks like this:
all:
- language_interface
- language_content
- language_url
configurable:
- language_interface
negotiation:
language_content:
enabled:
language-interface: 0
language_url:
enabled:
language-url: 0
language-url-fallback: 1
language_interface:
enabled:
language-url: 0
Here's a quick explanation of each key:
- all: Lists all the language types.
- configurable: Lists all the configurable language types.
- negotiation: For each language types, it lists which negotiation methods are enabled. In addition to the enabled key, each language types can also contain method_weights, which lists the weights of the methods.
In D7, all those settings are spread across multiple variables:
- language_types
- language_negotiation_language
- language_negotiation_language_content
- language_negotiation_language_url
- locale_language_providers_weight_language
- locale_language_providers_weight_language_content (optional)
- locale_language_providers_weight_language_url (optional)
The language_types variable contains an array of the language types as the keys and booleans as the values, indicating if they are configurable or not.
The language_negotiation_* variables contain arrays of the negotiation methods enabled for that language type.
The locale_language_providers_weight_* variables contain arrays of the negotiation method weights.
Another thing to know is that the negotiation method names are not the same in D7 an D8. In D7 they are prefixed by 'locale_' and in D8 the are prefixed with 'language_'.
The Drupal 6 (and to some degree Drupal 7) counterpart to this is #2225293: Migrate D6 and D7 language negotiation settings, which migrates the global negotiation configurations (eg. domains and prefixes) for both Drupal 6 and 7; and also creates a hardwired structure similar to this for Drupal 6, because the language flexibility is much less versatile there.
Comment | File | Size | Author |
---|---|---|---|
#41 | interdiff-38-41.txt | 8.64 KB | maxocub |
#41 | 2353709-41.patch | 13.85 KB | maxocub |
#38 | interdiff-36-38.txt | 690 bytes | maxocub |
#38 | 2353709-38.patch | 9.18 KB | maxocub |
#36 | 2353709-36.patch | 8.51 KB | maxocub |
Comments
Comment #1
sidharthapHere is my first try to work on the migrate project. I'm not sure if I've done it correctly. Please suggest.
Comment #2
benjy CreditAttribution: benjy commentedHi @siharthap, that looks pretty good. We're just waiting on this patch: https://www.drupal.org/node/2410625
Which will automate all the dumps for D7 and then we're going to start full speed on the D7 migrate path.
Comment #3
sidharthapThank You @benjy.
Comment #4
jcost CreditAttribution: jcost commentedWill need to be submitted again to Core since moving from sandbox.
Comment #5
quietone CreditAttribution: quietone commentedI've completed moving this to the language module and it's running fine locally.
But I can't find variable 'language_interface' in D7, where is it defined?
What about the other language variables; language_count, language_negotiation_language, language_negotiation_language_content and language_negotiation_language_url? Are these to be migrated as well?
Comment #6
quietone CreditAttribution: quietone commentedAccidentally lost my previous works (too many distractions today). So here is a quick reroll, done just before going to bed. It needs more work and I'm too tired to do so now. But, let's see what testbot finds.
Comment #7
quietone CreditAttribution: quietone commentedChange parent issue from the duplicate to the current one.
Comment #8
quietone CreditAttribution: quietone commentedReroll remove unused use statements
Comment #10
quietone CreditAttribution: quietone commentedNot sure how I messed up that edit.
Comment #11
phenaproximaNo need for static_map; IIRC the config system will cast 0 and 1 to boolean, based on the config schema.
Ditto.
Nit: There's an extra space here, at the beginning of the line.
Nit: There's an extra line between the doc block and the class.
Nit: Need a blank line between the class declaration and this doc comment.
Should be $this->config().
Comment #12
quietone CreditAttribution: quietone commentedThx phenaproxima.
1-6 fixed. No interdiff because of Variable.php.
Comment #14
phenaproximaThank you, config schema checker :) Looks like "negotiation" is misspelled in the migration...
Comment #15
quietone CreditAttribution: quietone commentedIt's more than a typo, as this failing patch will show.
Comment #16
phenaproximaIt looks like these are not asserting the values that are in the dump files...?
Comment #19
phenaproximaComment #20
quietone CreditAttribution: quietone commentedRevisiting this and there is confusion on the source and the destination.
The IS identifies 3 variables to migrate:
And here is the current test data for the D7 variable, language_types.
a:3:{s:8:"language";b:1;s:16:"language_content";b:0;s:12:"language_url";b:0;}
So, what are the configuration destinations for 'language', 'language_content' and 'language url'?
Comment #21
phenaproximaTurns out these variables do not exist in Drupal 7; instead, they refer to the complex language_negotiation_* variables, which are complicated enough to need their own migrations -- possibly a set of migrations. They pack a lot of data into a single variable, which is unpacked in the Drupal 8 language.types config object.
Comment #22
quietone CreditAttribution: quietone commentedWhich variables are you referring to?
This definitely exists in D7:
language_types : a:3:{s:8:"language";b:1;s:16:"language_content";b:0;s:12:"language_url";b:0;}
Comment #23
quietone CreditAttribution: quietone commentedComment #24
quietone CreditAttribution: quietone commentedComment #25
quietone CreditAttribution: quietone commentedRemoved tag.
Comment #26
quietone CreditAttribution: quietone commentedComment #29
maxocub CreditAttribution: maxocub commentedI think there's five D7 variables that we need here:
language_negotiation_language
who lists negotiation methods for the interface (language_interface in D8)language_negotiation_language_content
who list negotiation methods for the contentlanguage_negotiation_language_url
who lists negotiation methods for the urllanguage_types
who specifies which of the three language types above are configurablelocale_language_providers_weight_language
who contains the weight of the negotiation methodsI've been working on the D6 version of this issue (#2225293: Migrate D6 and D7 language negotiation settings), so I might give it a try.
Comment #30
Gábor Hojtsy@maxocub: yeah that analysis seems fine, the D7 negotiation settings are similar but a bit more limited than Drupal 8, so the migration is more 1-1 with Drupal 8 than Drupal 6, where you need to generate a whole bunch of things for D8.
Comment #31
maxocub CreditAttribution: maxocub commented@Gábor Hojtsy: In D7, the negotiation methods for
language_content
andlanguage_url
are fixed and non-configurable. Could we just assume they still are and use default values in the migration (like we did with D6) or do we migrate them in case someone altered them of added new ones?I ask because it's a bit complicated to migrate them since they don't have the same names (locale-url instead of language-url, language-default instead of language-selected, etc.) and are spread across a few variables. I I haven't found a way to use the existing plugins.
Also, if someone altered and/or added new language types, should we try to see if the variables
"locale_language_providers_weight_$type"
exist?Comment #32
iMiksuComment #33
anish.a CreditAttribution: anish.a at Axelerant commentedThe file core/modules/migrate_drupal/src/Tests/Table/d7/Variable.php is removed at following commit. Reroll is not trivial.
Comment #34
maxocub CreditAttribution: maxocub commentedI'm working on a reroll, and I'm starting from scratch.
Comment #35
Gábor Hojtsy1. Migrating contrib types, I don't think we can do in the core migration, so I would not try to do that.
2. language-default was not configurable in drupal 7, so we can assume that it is a fixed thing and migrate to language-selected with a setting tied to default language
3. language_content is definitely not fixed, if you had entity_translation installed in Drupal 7
4. Re language_url, I don't know if there is a contrib module that makes it configurable, I don't think not migrating it from the variables is easier since we need to migrate the two other types, and language_url can consist of settings for the same types, so can use the same migrations(?)
I think those were all the questions? Hopefuly helpful :)
Comment #36
maxocub CreditAttribution: maxocub commentedHere's a new patch. I haven't included an interdiff since I started from scratch.
I haven't found a way to use existing process plugins.
I will wait for reviews before adding unit tests for the new plugins.
Comment #38
maxocub CreditAttribution: maxocub commentedComment #39
phenaproximaAssigning to myself for review.
Comment #40
phenaproximaThis is looking pretty good, but the new process plugins need tests.
Can we check that $value is an array and throw a MigrateException if it isn't?
For each of these cases, can we just return the value directly instead of setting $new_value and breaking? I think it would be a little cleaner that way.
Before this, let's check that $value is an array and throw MigrateException if not.
Should be
if (!empty($this->configuration['filter_configurable']))
.Comment #41
maxocub CreditAttribution: maxocub commentedMade the changes from #40 and added unit tests.
Comment #42
Gábor HojtsyReviewed for the migration mappings, it all looks good for what it needs to do. Also confirmed that the Drupal 6 part of this is covered in #2225293: Migrate D6 and D7 language negotiation settings and the missing elements for Drupal 7 language negotiation are there too, so these two issues are complimentary to solve all the core language negotiation setting migrations from both Drupal 6 and 7.
Comment #44
alexpottCommitted and pushed 635e4ee to 8.3.x and 641e529 to 8.2.x. Thanks!
Committed to 8.2.x because migrate_drupal is still experimental.
Comment #47
Gábor HojtsyYay, thanks!
Comment #49
maxocub CreditAttribution: maxocub as a volunteer and commented