Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / comment / src / Plugin / migrate / source / d6 / Comment.php
index b2511c59a53e9da92e4a2f9e2b58d87e4e61a5fa..5671d4f15665a95fab2b5c4be2341abfe763a6ea 100644 (file)
@@ -25,7 +25,7 @@ class Comment extends DrupalSqlBase {
       'mail', 'homepage', 'format',
     ]);
     $query->innerJoin('node', 'n', 'c.nid = n.nid');
-    $query->fields('n', ['type']);
+    $query->fields('n', ['type', 'language']);
     $query->orderBy('c.timestamp');
     return $query;
   }
@@ -61,6 +61,13 @@ class Comment extends DrupalSqlBase {
     // In D6, status=0 means published, while in D8 means the opposite.
     // See https://www.drupal.org/node/237636.
     $row->setSourceProperty('status', !$row->getSourceProperty('status'));
+
+    // If node did not have a language, use site default language as a fallback.
+    if (!$row->getSourceProperty('language')) {
+      $language_default = $this->variableGet('language_default', NULL);
+      $language = $language_default ? $language_default->language : 'en';
+      $row->setSourceProperty('language', $language);
+    }
     return $row;
   }
 
@@ -84,6 +91,7 @@ class Comment extends DrupalSqlBase {
       'mail' => $this->t("The comment author's email address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on."),
       'homepage' => $this->t("The comment author's home page address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on."),
       'type' => $this->t("The {node}.type to which this comment is a reply."),
+      'language' => $this->t("The {node}.language to which this comment is a reply. Site default language is used as a fallback if node does not have a language."),
     ];
   }