Problem/Motivation

i18n site offline message is not migrated.

This is blocking
#2970849: i18n Variable to config: user settings and user.mail
#2970847: i18n Variable to config: system site settings [d7]

Proposed resolution

Migrate i18n variable, site offline message to config.

This is the first of the i18n variable migrations for Drupal 7 and includes a new source plugin because in D7 the variables are stored in the variable_store table, not variable, where the data may or may not be serialized. There is still much in common with the Drupal 6 VariableTranslation source plugin so a base class is added.

Remaining tasks

Write migration.
Write tests, includes updating the drupal7 test fixture.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Comments

quietone created an issue. See original summary.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

quietone’s picture

Status: Postponed » Needs review
StatusFileSize
new35.14 KB

Right, let's make a start. This has a new source plugin to access the data in the d7 table, variable_store and of course changes to the fixture (yuck).

the source plugin shares code with the d6 version, so there is still work to do. Haven't run all the tests, so lets see what testbot finds.

Status: Needs review » Needs work

The last submitted patch, 3: 2970848-3.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new45.79 KB
new12.96 KB

This add a base class for the VariableTranslation source plugin, changes the id of the d6 source plugin from variable_translation to d6_variable_translation, and attempts to get the various MigrateUpgrade tests working correctly.

No interdiff because there are

Status: Needs review » Needs work

The last submitted patch, 5: 2970848-5.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new44.95 KB
new1.7 KB

Add a single quote to the test string for MigrateUPgrade7NoMultilingualTest and remove debug line of code (an exit() that stops a test early).

Status: Needs review » Needs work

The last submitted patch, 7: 2970848-7.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new45.21 KB
new640 bytes

Update the tour entity count

Status: Needs review » Needs work

The last submitted patch, 9: 2970848-9.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new45.21 KB
new1.78 KB

Now, attempt to fix the coding standard errors. I've since found out the PhpStorm has magically decided to not run code inspections.

quietone’s picture

Issue summary: View changes
Issue tags: +blocker

Because this has a new source plugin for the D7 variable translations, it is a blocker for the other migrations.

Update IS.

maxocub’s picture

Status: Needs review » Needs work
+++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/VariableTranslation.php
@@ -2,42 +2,17 @@
- *   id = "variable_translation",
+ *   id = "d6_variable_translation",

I did not do a full review yet, but don't think we can change this plugin ID without adding a BC layer.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new49.05 KB
new3.23 KB

Yes, of course. This add the deprecation.

Status: Needs review » Needs work

The last submitted patch, 14: 2970848-14.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new50.22 KB
new1.17 KB

Add @legacy to the two failing tests.

quietone’s picture

Issue summary: View changes

Added the issues this is blocking to the IS

maxocub’s picture

Status: Needs review » Needs work
Issue tags: +Needs change record

I'm wondering if the renaming of the variable_translation source plugin to d6_variable_translation is really necessary? It's for consistency with the new d7_variable_translation plugin, but we end up with 3 classes: d6/VariableTranslation, d6/D6VariableTranslation and d7/VariableTranslation, which is also confusing. What do you think is better?

  1. +++ b/core/modules/config_translation/tests/src/Kernel/Migrate/d7/MigrateSystemMaintenanceTranslationTest.php
    @@ -0,0 +1,38 @@
    + * @group legacy
    

    Why is this new test in the @legacy group?

  2. +++ b/core/modules/config_translation/tests/src/Kernel/Migrate/d7/MigrateSystemMaintenanceTranslationTest.php
    @@ -0,0 +1,38 @@
    + * Upgrade i18n maintenance variables to system.*.yml.
    

    This class description should says something like "Tests the migration of...".

  3. +++ b/core/modules/config_translation/tests/src/Kernel/Migrate/d7/MigrateSystemMaintenanceTranslationTest.php
    @@ -0,0 +1,38 @@
    + * @group legacy
    

    Why is this new test in the @legacy group?

  4. +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/VariableTranslationBase.php
    @@ -0,0 +1,58 @@
    + * Variable Translation source plugin base class.
    

    s/Translation/translation

  5. +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/VariableTranslationBase.php
    @@ -0,0 +1,58 @@
    +    return new \ArrayIterator($this->values());
    

    I'm not sure about this, but since this abstract base class use the values() method but does not provide it, should we not add an abstract values() method? So people extending this class will be warn that they need to implement this method?

  6. +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/VariableTranslationBase.php
    @@ -0,0 +1,58 @@
    +    $ids['language']['type'] = 'string';
    

    Is it really enough to only use the language as ID? What happen if we are fetching more than one variable?

  7. +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/VariableTranslation.php
    @@ -2,10 +2,7 @@
    +@trigger_error('VariableTranslation is deprecated in Drupal 8.7.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Plugin\migrate\source\d6\VariableTranslationD6 instead. See https://www.drupal.org/node/2970848 for more information.', E_USER_DEPRECATED);
    

    This should use the format from this page: https://www.drupal.org/core/deprecation#how-class. In particular, the 'see' link should point to a change record.

    Also, the new class name is D6VariableTranslation.

  8. +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/VariableTranslation.php
    @@ -14,88 +11,11 @@
    + * @deprecated in Drupal 8.7.x, to be removed before Drupal 9.0.x. Use
    + * \Drupal\migrate_drupal\Plugin\migrate\source\d6\VariableTranslationD6
    + * instead.
    + *
    + * See https://www.drupal.org/node/2970848 for more information.
    

    Same here.

  9. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7NoMultilingualTest.php
    @@ -168,6 +169,28 @@ protected function getAvailablePaths() {
    +      'entity_translation_i18n_menu',
    +      'entity_translation_upgrade',
    +      'i18n',
    +      'i18n_block',
    +      'i18n_contact',
    +      'i18n_field',
    +      'i18n_forum',
    +      'i18n_menu',
    +      'i18n_node',
    +      'i18n_path',
    +      'i18n_redirect',
    +      'i18n_select',
    +      'i18n_string',
    +      'i18n_sync',
    +      'i18n_taxonomy',
    +      'i18n_translation',
    +      'i18n_user',
    +      'variable',
    +      'variable_admin',
    +      'variable_realm',
    +      'variable_store',
    +      'variable_views',
    

    Why all those new missing paths?

  10. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7ReviewPageTest.php
    @@ -138,6 +138,29 @@ protected function getAvailablePaths() {
    +      'entity_translation_i18n_menu',
    +      'entity_translation_upgrade',
    +      'i18n',
    +      'i18n_block',
    +      'i18n_contact',
    +      'i18n_field',
    +      'i18n_forum',
    +      'i18n_menu',
    +      'i18n_node',
    +      'i18n_path',
    +      'i18n_redirect',
    +      'i18n_select',
    +      'i18n_string',
    +      'i18n_sync',
    +      'i18n_taxonomy',
    +      'i18n_translation',
    +      'i18n_user',
    +      'i18n_variable',
    +      'variable',
    +      'variable_admin',
    +      'variable_realm',
    +      'variable_store',
    +      'variable_views',
    

    Same here.

  11. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php
    @@ -86,7 +87,7 @@ protected function getEntityCounts() {
    +      'tour' => 5,
    

    Why is there a new tour?

quietone’s picture

StatusFileSize
new50.16 KB
new1.76 KB

A small step, fixes for 18-1, 2, 3, and 4. Note that 1 and 3 are the same.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new49.33 KB
new2.79 KB

Test failure in #19 looks unrelated.

18.6. The variable source plugins are different than others. What happens in that each row has a property for the language and one each for every variable requested. An easy way to see this is in the source plugin test, this is from the d7 test.
18.7 and 8. Format of deprecation and trigger_error changed. However, still to do is the correct link to a change record.

$tests[0]['expected_data'] = [
      [
        'language' => 'fr',
        'site_slogan' => 'fr - site slogan',
        'user_mail_status_blocked_subject' => 'fr - BEGONE!',
      ],
      [
        'language' => 'is',
        'site_slogan' => 'is - site slogan',
      ],
    ];

18.9 Yes, that is wrong. fixed.
18.10 Because in this type of review page test all the modules in the source are enabled and i18n has quite a few modules.

TODO:
18.5 and 11

quietone’s picture

Status: Needs review » Needs work

18.11 When config_translation is enabled the tour tour.tour.locale entity is added.

18.5 I wasn't too sure about this base class myself. Maybe it would be better to not have it. There plugins are atypical anyway and it probably isn't a good idea to add to that.

TODO:
18.5
Add change record and update the link to change record in the deprecations.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new49.32 KB

Needs a reroll.

quietone’s picture

StatusFileSize
new46.93 KB
new1.91 KB

Remove the new VariableBase class.

quietone’s picture

StatusFileSize
new46.97 KB
new1.28 KB

Added change record.

quietone’s picture

This is now ready for review.

maxocub’s picture

Status: Needs review » Needs work
Issue tags: -Needs change record

Let's get this issue moving since it's blocking other issues.

  1. +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/D6VariableTranslation.php
    @@ -11,11 +11,11 @@
    +class D6VariableTranslation extends DrupalSqlBase {
    
    +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/VariableTranslation.php
    @@ -14,88 +11,10 @@
    +class VariableTranslation extends D6VariableTranslation {}
    

    I think I would prefer if the BC layer class was the one called D6VariableTranslation so that When Drupal 9 comes we will be able to remove it and end up with the better name VariableTranslation for the remaining class. It won't impact anyone who my have been extending the class (if any) because we make it extend the new class anyway.

  2. +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7ReviewPageTest.php
    @@ -138,6 +138,29 @@ protected function getAvailablePaths() {
       protected function getMissingPaths() {
         return [
    +      'entity_translation_i18n_menu',
    +      'entity_translation_upgrade',
    

    I don't understand how this i18n patch needs to add entity_translation_* modules to the missing paths.

  3. +++ b/core/modules/migrate_drupal/tests/fixtures/drupal7.php
    @@ -1730,6 +1730,34 @@
    +->values(array(
    +  'bid' => '49',
    +  'module' => 'locale',
    +  'delta' => 'language_content',
    +  'theme' => 'bartik',
    +  'status' => '0',
    +  'weight' => '0',
    +  'region' => '-1',
    +  'custom' => '0',
    +  'visibility' => '0',
    +  'pages' => '',
    +  'title' => '',
    +  'cache' => '-1',
    +))
    +->values(array(
    +  'bid' => '50',
    +  'module' => 'locale',
    +  'delta' => 'language_content',
    +  'theme' => 'seven',
    +  'status' => '0',
    +  'weight' => '0',
    +  'region' => '-1',
    +  'custom' => '0',
    +  'visibility' => '0',
    +  'pages' => '',
    +  'title' => '',
    +  'cache' => '-1',
    +))
    

    Are those new blocks necessary for this patch?

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new43.41 KB
new8.24 KB

1. Fixed, I think I got it right.
2. They are needed because the that ReviewPageTest enables all the modules on the source site, except test and example modules. And since they are enabled they will appear in the UI lists.
3. I don't think they are so they are removed.

TODO: Update the CR.

maxocub’s picture

Status: Needs review » Needs work

Re #27.2: Thanks for the explanation, now I get it.

Sorry I didn't find those nits in my previous review, but I think those are the last ones:

  1. +++ b/core/modules/config_translation/tests/src/Kernel/Migrate/d7/MigrateSystemMaintenanceTranslationTest.php
    @@ -0,0 +1,37 @@
    +    $this->assertIdentical('is - This is a custom maintenance mode message.', $config->get('message'));
    

    Should be assertSame().

  2. +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/D6VariableTranslation.php
    @@ -0,0 +1,20 @@
    + * Drupal i18n_variable source from database.
    

    As @masipila would say, class description should start with a 3rd person verb ;)

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new43.42 KB
new2.31 KB

1. Fixed
2. Fixed and did the same for the D7 source plugin.
3. Updated the CR

And that covers all the todos in this patch so far. :-)

maxocub’s picture

Status: Needs review » Reviewed & tested by the community

This looks good to go, thanks @quietone!

The last submitted patch, 19: interdiff-16-19.patch, failed testing. View results

maxocub’s picture

Status: Reviewed & tested by the community » Needs work

I'm starting to read in other issues that plugin deprecation should be done in a constructor, as well as in Drupal core deprecation policy. On the other hand, migrate if full of deprecation in the global namespace.
I guess we should start doing the deprecation in the constructor, what do you think?

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new43.88 KB
new1.99 KB

Yes, we should.

maxocub’s picture

Status: Needs review » Reviewed & tested by the community

Perfect, thanks! Back to RTBC.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Needs review
  1. +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/D6VariableTranslation.php
    @@ -0,0 +1,32 @@
    +/**
    + * Gets Drupal i18n_variable source from database.
    + *
    + * @deprecated in Drupal 8.7.x and will be removed in Drupal 9.0.x.
    + * Use \Drupal\migrate_drupal\Plugin\migrate\source\d6\VariableTranslation.
    + *
    + * @see https://www.drupal.org/node/3006487
    + *
    + * @MigrateSource(
    + *   id = "variable_translation",
    + *   source_module = "system",
    + * )
    + */
    +class D6VariableTranslation extends VariableTranslation {
    

    Why are we just adding a source just to immediately deprecate it?

  2. +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/VariableTranslation.php
    --- a/core/modules/migrate_drupal/tests/fixtures/drupal7.php
    +++ b/core/modules/migrate_drupal/tests/fixtures/drupal7.php
    
    +++ b/core/modules/migrate_drupal/tests/fixtures/drupal7.php
    +++ b/core/modules/migrate_drupal/tests/fixtures/drupal7.php
    @@ -48329,7 +48329,227 @@
    
    @@ -48329,7 +48329,227 @@
       'bootstrap' => '0',
       'schema_version' => '7009',
       'weight' => '11',
    -  'info' => 'a:14:{s:4:"name";s:18:"Entity Translation";s:11:"description";s:58:"Allows entities to be translated into different languages.";s:7:"package";s:33:"Multilingual - Entity Translation";s:4:"core";s:3:"7.x";s:9:"configure";s:40:"admin/config/regional/entity_translation";s:12:"dependencies";a:1:{i:0;s:14:"locale (>7.14)";}s:17:"test_dependencies";a:2:{i:0;s:17:"pathauto:pathauto";i:1;s:5:"title";}s:5:"files";a:15:{i:0;s:40:"includes/translation.handler_factory.inc";i:1;s:32:"includes/translation.handler.inc";i:2;s:40:"includes/translation.handler.comment.inc";i:3;s:37:"includes/translation.handler.node.inc";i:4;s:46:"includes/translation.handler.taxonomy_term.inc";i:5;s:37:"includes/translation.handler.user.inc";i:6;s:32:"includes/translation.migrate.inc";i:7;s:29:"tests/entity_translation.test";i:8;s:49:"views/entity_translation_handler_relationship.inc";i:9;s:57:"views/entity_translation_handler_field_translate_link.inc";i:10;s:48:"views/entity_translation_handler_field_label.inc";i:11;s:55:"views/entity_translation_handler_filter_entity_type.inc";i:12;s:52:"views/entity_translation_handler_filter_language.inc";i:13;s:62:"views/entity_translation_handler_filter_translation_exists.inc";i:14;s:48:"views/entity_translation_handler_field_field.inc";}s:7:"version";s:7:"7.x-1.0";s:7:"project";s:18:"entity_translation";s:9:"datestamp";s:10:"1522600694";s:5:"mtime";i:1522600694;s:3:"php";s:5:"5.2.4";s:9:"bootstrap";i:0;}',
    +  'info' => 'a:14:{s:4:"name";s:18:"Entity Translation";s:11:"description";s:58:"Allows entities to be translated into different languages.";s:7:"package";s:33:"Multilingual - Entity Translation";s:4:"core";s:3:"7.x";s:9:"configure";s:40:"admin/config/regional/entity_translation";s:12:"dependencies";a:1:{i:0;s:14:"locale (>7.14)";}s:17:"test_dependencies";a:2:{i:0;s:17:"pathauto:pathauto";i:1;s:5:"title";}s:5:"files";a:15:{i:0;s:40:"includes/translation.handler_factory.inc";i:1;s:32:"includes/translation.handler.inc";i:2;s:40:"includes/translation.handler.comment.inc";i:3;s:37:"includes/translation.handler.node.inc";i:4;s:46:"includes/translation.handler.taxonomy_term.inc";i:5;s:37:"includes/translation.handler.user.inc";i:6;s:32:"includes/translation.migrate.inc";i:7;s:29:"tests/entity_translation.test";i:8;s:49:"views/entity_translation_handler_relationship.inc";i:9;s:57:"views/entity_translation_handler_field_translate_link.inc";i:10;s:48:"views/entity_translation_handler_field_label.inc";i:11;s:55:"views/entity_translation_handler_filter_entity_type.inc";i:12;s:52:"views/entity_translation_handler_filter_language.inc";i:13;s:62:"views/entity_translation_handler_filter_translation_exists.inc";i:14;s:48:"views/entity_translation_handler_field_field.inc";}s:7:"version";s:7:"7.x-1.0";s:7:"project";s:18:"entity_translation";s:9:"datestamp";s:10:"1522600694";s:5:"mtime";i:1535762879;s:3:"php";s:5:"5.2.4";s:9:"bootstrap";i:0;}',
    +))
    +->values(array(
    +  'filename' => 'sites/all/modules/entity_translation/entity_translation_i18n_menu/entity_translation_i18n_menu.module',
    +  'name' => 'entity_translation_i18n_menu',
    

    How come all these i18n modules were missing in the D7 fixtures earlier?

quietone’s picture

35.1 The existing variable translation source plugin in source/d6/VariableTranslation is named 'variable_translation' and not 'd6_variable_translation' as is typical and implies it will be used for both d6 and d7. Now that this patch introduces a new source plugin 'd7_variable_translation' which would leave us with 'variable_translation' and 'd7_variable_translation' which is confusing. It makes sense to change 'variable_translation' to 'd6_variable_translation' to avoid that. That can be done by introducing a new class with the new d6 source plugin annotation. But what do we call the new class since d6/VariableTranslation.php already exists and that is the class name we would prefer to keep. Originally I solved this by making a new class D6VariableTranslation #24 but maxocub suggested in #26 that it would be simpler to move the existing d6 annotation to a new immediately deprecated source plugin class and change the annotation in the existing d6/VariableTranslation.

35.2 This is the first patch that enables any of the i18n modules for D7 so it is the first time they are found. And they all need to be in the source db for the MigrateUpgradeD7ReviewPageTest which will enable all modules in the source.

gábor hojtsy’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, makes sense.

  • Gábor Hojtsy committed 3480039 on 8.7.x
    Issue #2970848 by quietone, maxocub: i18n Variable to config: site...

  • Gábor Hojtsy committed 783ba6b on 8.6.x
    Issue #2970848 by quietone, maxocub: i18n Variable to config: site...
gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Thanks a lot!

heddn’s picture

Published CR.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.