Problem/Motivation

Noticed that a test is missing that should have been in #3008029: Migrate D7 i18n field option translations. It is the test of the migration of the field option translations for booleans, like checkboxes.

Then the fix caused an error with Postgres and that exposed that the bundle was not included in the source IDs.

Proposed resolution

This adds data to the fixture and a test of the field option translation for a checkbox.

Add 'bundle' to the IDs in the source plugin. Without that only the first row for field_boolean was being processed and that happened to be 'test_content_type' for mysql and sqlite and 'blog' for 'postgres. Now, all bundles will be processed.

Note that adding the bundle as a key resulted in a key that was too long resulting in 'Syntax error or access violation: 1071 Specified key was too long; max key length is 3072' for MySQl. That was fixed in #3098282: [backport] SQL error if migration has too many ID fields and the key can simply be added now.

CommentFileSizeAuthor
#53 3103031-53.patch15.5 KBquietone
#53 diff-51-53.txt2.84 KBquietone
#51 3103031-51.patch15.36 KBquietone
#51 diff-49-51.txt2.43 KBquietone
#50 3103031-49.patch15.35 KBquietone
#49 3103031-49.txt15.35 KBquietone
#49 interdiff-47-49.txt473 bytesquietone
#47 3103031-47.patch14.71 KBquietone
#47 diff-46-47.txt2.21 KBquietone
#45 3103031-46.patch14.56 KBquietone
#45 interdiff-44-46.txt2.11 KBquietone
#44 3103031-44.patch12.45 KBquietone
#44 interdiff-42-44.txt794 bytesquietone
#42 3103031-42.patch12.44 KBquietone
#42 diff-32-42.txt4.4 KBquietone
#32 3103031-32.patch13.13 KBquietone
#32 interdiff-26-32.txt843 bytesquietone
#26 interdiff-24-26.txt763 bytesquietone
#26 3103031-26.patch12.59 KBquietone
#24 3103031-24.patch12.38 KBquietone
#24 interdiff-21-24.txt2.19 KBquietone
#12 3103031-12.patch11.45 KBquietone
#12 interdiff-10.12.txt1.28 KBquietone
#10 3103031-10.patch11.5 KBquietone
#10 interdiff-8-10.txt562 bytesquietone
#8 3103031-8.patch11.43 KBquietone
#8 interdiff-6-8.txt7.98 KBquietone
#6 3103031-6.patch3.32 KBquietone
#6 interdiff-4-6.txt633 bytesquietone
#4 interdiff-2-4.txt2.24 KBquietone
#4 3103031-4.patch10.81 KBquietone
#2 3103031-2.patch8.85 KBquietone
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quietone created an issue. See original summary.

quietone’s picture

Status: Active » Needs review
FileSize
8.85 KB

Status: Needs review » Needs work

The last submitted patch, 2: 3103031-2.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
10.81 KB
2.24 KB

Add missing field_revision_field_checkbox table.

Status: Needs review » Needs work

The last submitted patch, 4: 3103031-4.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
633 bytes
3.32 KB

Yes, there is another field config so increase the entity count

Status: Needs review » Needs work

The last submitted patch, 6: 3103031-6.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
7.98 KB
11.43 KB

Well, that was a bad patch, it didn't have the changes to the test fixture.

Status: Needs review » Needs work

The last submitted patch, 8: 3103031-8.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
562 bytes
11.5 KB

And update the number of field_storage_config entities.

Wim Leers’s picture

Title: Add missig test of field option translations for booleans » Add missing test of field option translations for booleans
Status: Needs review » Needs work
  1. +++ b/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceOptionTranslationTest.php
    @@ -0,0 +1,81 @@
    +  public static $modules =
    +    [
    +      'comment',
    +      'config_translation',
    +      'datetime',
    +      'file',
    +      'image',
    +      'language',
    +      'link',
    +      'locale',
    +      'menu_ui',
    +      'node',
    +      'system',
    +      'taxonomy',
    +      'telephone',
    +      'text',
    +    ];
    

    🔎 Weird indentation going on here.

  2. +++ b/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceOptionTranslationTest.php
    @@ -0,0 +1,81 @@
    +   * Tests migration of file variables to file.settings.yml.
    

    🤔 I don't think this comment is accurate?

quietone’s picture

@Wim Leers, thanks. Should be fixed now.

Wim Leers’s picture

This looks good to me now, but I don't know enough about these particular source + destination to RTBC this. Hopefully my review in #11 and the iteration in #12 make it easier for the next person to RTBC this :)

NickDickinsonWilde’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me, but never done any D7 multilingual stuff only D8, so not the highest confidence. But 2 somewhat hesitant +1s is somewhat equal to a RTBC I figure.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

New test looks good to me.

Committed and pushed 677f9d42d8 to 9.0.x and e4220e5ce6 to 8.9.x. Thanks!

  • alexpott committed 677f9d4 on 9.0.x
    Issue #3103031 by quietone, Wim Leers: Add missing test of field option...

  • alexpott committed e4220e5 on 8.9.x
    Issue #3103031 by quietone, Wim Leers: Add missing test of field option...
alexpott’s picture

Status: Fixed » Needs work

Unfortunately this broke Postgres so reverting.

  • alexpott committed 9f121c8 on 8.9.x
    Revert "Issue #3103031 by quietone, Wim Leers: Add missing test of field...

  • alexpott committed 89bdd89 on 9.0.x
    Revert "Issue #3103031 by quietone, Wim Leers: Add missing test of field...
xjm’s picture

Just a reminder that anything interacting directly with the DB layer (including test fixtures) should always be tested on Postgres and SQLite before commit. Thanks!

quietone’s picture

Assigned: Unassigned » quietone

I should be able to get to this this week.

DamienMcKenna’s picture

Issue tags: +PostgreSQL
quietone’s picture

Added 'bundle' to the IDs in the source plugin. Without that only the first row for field_boolean was being processed and that happened to be 'test_content_type' for mysql and sqlite and 'blog' for 'postgres. Now, all bundles will be processed.

The test is updated to test both 'test_content_type' and 'blog'.

Status: Needs review » Needs work

The last submitted patch, 24: 3103031-24.patch, failed testing. View results

quietone’s picture

Hmm. I thought I ran the test with mysql, must have made a mistake. And new errors as well.

OK, here is a fix. The source IDs in FieldOptionTranslation now have a max_length that is the same as that in the d7 schema. This time I am sure I tested locally with Mysql.

quietone’s picture

The sqlite fail is unrelated it is in, Media_library.Drupal\Tests\media_library\FunctionalJavascript\WidgetUploadTest. See #3066447: [random test failure] Random failures building media library form after uploading image (WidgetUploadTest).

quietone’s picture

Assigned: quietone » Unassigned

Ready for review.

NickDickinsonWilde’s picture

Status: Needs review » Reviewed & tested by the community

LGTM

alexpott’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/modules/field/src/Plugin/migrate/source/d7/FieldOptionTranslation.php
@@ -62,8 +62,15 @@ public function fields() {
-        'language' => ['type' => 'string'],
+        'language' => [
+          'type' => 'string',
+          'max_length' => '12',
+        ],
         'property' => ['type' => 'string'],
+        'bundle' => [
+          'type' => 'string',
+          'max_length' => '32',
+        ],

This is the only place where we've done this. I'm concerned that these might not be correct in some rare instance. How about adding an order by bundle in \Drupal\field\Plugin\migrate\source\d7\FieldOptionTranslation::query()?

quietone’s picture

Assigned: Unassigned » quietone

I'll try to respond to this in a few days.

quietone’s picture

@alexpott. Thanks for the review.

The problem here is not about ordering. The source query needs to have 5 sourceIDs so that all the needed rows are processed but with 5 sourceIDs the key length is too long. Without the 5 IDs SourcePluginBase::next() will only process the first row of a set that where the first 4 sourceIDs are the same, because it looks at the map table and sees that a row with these source keys has been processed. The bundle really needs to be a key.

Typically, we just add the ID and use the default length. That is what was done in #24 which results in the error, "SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 3072 bytes: "

Are there any other ways to solve this?

Also, I was getting a duplicate column error so the query is modified for that. I didn't run the test locally (I'm off to bed) but it worked fine with drush.

quietone’s picture

Assigned: quietone » Unassigned
heddn’s picture

Adding a new column into the id map has BC implications for existing migrations. Do we need to handle this gracefully for sites that might be doing incremental migrations?

quietone’s picture

Issue summary: View changes
Status: Needs review » Needs work

Good point. I think some hands on testing to be sure about incrementals is needed.

heddn’s picture

Category: Task » Bug report
Issue tags: +Needs title update

And this seems to have extended beyond just adding test coverage and seems to be fixing a bug. Needs a better title.

quietone’s picture

Title: Add missing test of field option translations for booleans » Add bundle to the sourceIDs to FieldOptionTranslation source plugin
Issue tags: -Needs title update

Yes it does

quietone’s picture

Found another issue reporting the same problem with the key length being greater that 3072bytes, #3098282: [backport] SQL error if migration has too many ID fields

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

quietone’s picture

Issue summary: View changes
Status: Needs work » Postponed

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

quietone’s picture

Issue summary: View changes
Status: Postponed » Needs review
FileSize
4.4 KB
12.44 KB

No longer postponed since #3098282: [backport] SQL error if migration has too many ID fields was committed.

And a reroll.

Status: Needs review » Needs work

The last submitted patch, 42: 3103031-42.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
794 bytes
12.45 KB

Silly me. Forgot to add these fixes.

quietone’s picture

quietone’s picture

Issue summary: View changes

Updating IS

quietone’s picture

Needed a reroll.

Status: Needs review » Needs work

The last submitted patch, 47: 3103031-47.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
FileSize
473 bytes
15.35 KB

FieldOptionTranslation needs another change, after #3187463: Fix "d7_field_option_translation" process plugin.

quietone’s picture

quietone’s picture

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Needed another reroll.

larowlan’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceOptionTranslationTest.php
@@ -0,0 +1,86 @@
+      'off_label' => 'fr - Stop',

surely this would be arrêter 😉

This looks good to me, but can only go into the current branches because #3098282: [backport] SQL error if migration has too many ID fields isn't backported yet

  • catch committed d88f334 on 9.3.x
    Issue #3103031 by quietone, alexpott, heddn, Wim Leers: Add bundle to...
catch’s picture

Version: 9.3.x-dev » 9.2.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 9.3.x and cherry-picked to 9.2.x, thanks!

  • catch committed 60bd72f on 9.2.x
    Issue #3103031 by quietone, alexpott, heddn, Wim Leers: Add bundle to...

Status: Fixed » Closed (fixed)

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