Problem/Motivation

1. If a multilingual support is disabled for a content type, there is no language_content_type variable for this content type. When d7_language_content_settings migration is executed, we get this warning:
No static mapping found for 'NULL' and no default value provided for destination 'default_langcode'.

2. If a content type is translatable with entity_translation, we get this message:
No static mapping found for ''4'' and no default value provided for destination 'default_langcode'.

Proposed resolution

Add a mapping for '4' (entity_translation) and make sure we don't get NULL values.

Remaining tasks

  • Write the patch
  • Review
  • Commit

User interface changes

None.

API changes

None.

Data model changes

None.

Comments

maxocub created an issue. See original summary.

maxocub’s picture

Version: 8.7.x-dev » 8.6.x-dev
Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new2.78 KB
new4.39 KB

Here's a failing patch and the fix.

The last submitted patch, 2: 2985784-2-test-only.patch, failed testing. View results

Status: Needs review » Needs work

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

maxocub’s picture

Status: Needs work » Needs review
StatusFileSize
new778 bytes
new2.78 KB
new5.15 KB

Fixed the failing test.

The last submitted patch, 5: 2985784-5-test-only.patch, failed testing. View results

heddn’s picture

Status: Needs review » Needs work
+++ b/core/modules/language/src/Plugin/migrate/source/d7/LanguageContentSettings.php
@@ -42,7 +42,7 @@ public function fields() {
-    $row->setSourceProperty('language_content_type', $this->variableGet('language_content_type_' . $type, NULL));
+    $row->setSourceProperty('language_content_type', $this->variableGet('language_content_type_' . $type, 0));

By changing this, all folks will silently start working with a default of 0 if they also don't update their yaml. Because it will have a default value of 0. And they might start pulling out their hair trying to figure out why 4 or any value but 0-3 just defaults to NULL. This probably deserves a change record.

maxocub’s picture

Status: Needs work » Needs review
StatusFileSize
new2.2 KB
new2.78 KB
new3.48 KB

Oh right. Instead of modifying the source plugin, we can also add a default value to the migration yaml. This also fix the problem without affecting people using the source plugin.

The last submitted patch, 8: 2985784-8-test-only.patch, failed testing. View results

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.

masipila’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

I reviewed and tested this manually.

Test results without patch #8
I'm able to reproduce the issue by having a content type which does not have multilingual options enabled and by having another content type which has Entity Translation enabled. (I updated the Issue Summary to better describe the scenario where this bug is triggered.)

Manual test results with patch #8 applied
No warnings are logged and migration results are as expected.

Conclusion

  • @heddn's feedback in #7 has been addressed. Patch #8 now handles this in the migration YAML instead of changing the behavior of the source plugin.
  • There is a failing test that demonstrates the issue.
  • Patch #8 passes the new test.
  • My manual tests are OK.
  • Patch looks good to me.
  • RTBC.
alexpott’s picture

Adding credit

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed a42433ef91 to 8.7.x and c34c4408de to 8.6.x. Thanks!

  • alexpott committed a42433e on 8.7.x
    Issue #2985784 by maxocub, heddn, masipila: No static mapping found in...

  • alexpott committed c34c440 on 8.6.x
    Issue #2985784 by maxocub, heddn, masipila: No static mapping found in...
alexpott’s picture

Backported to 8.6.x since this is a migrate drupal fix and that is stable only in 8.6.0

Status: Fixed » Closed (fixed)

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