We have an export from a database (non-drupal) in which rows are basically listed as:
row 1) id:1, langcode: nl
row 2) id:1, langcode: fr
row 3) id:1, langcode: en
I have configured the my_migration yml as follows:
source:
plugin: migration_custom
process:
nid:
plugin: migration
source: news_article_id
migration: my_migration
no_stub: true
langcode: langcode
...
destination:
plugin: entity:node
translations: true
The migration_custom class extends SqlBase and provides these fields:
- news_article_id, langcode
and the getIds() returns this array
[
'news_article_id' => [
'type' => 'integer',
],
'langcode' => [
'type' => 'string',
],
When running the migration, all rows are migrated, but are not linked as a translation of each other. When importing the 2nd row, a translation of the first, upon debugging I found that in the transform method of the process/Migration class, the returned destinations ids is this an array: array(0=>'2', 1=>'nl'). 2 being the nid of the node representing the first row.
The last part of the transform method however does this:
if ($destination_ids) {
if ($scalar) {
if (count($destination_ids) == 1) {
return reset($destination_ids);
}
}
else {
return $destination_ids;
}
}
Because the process plugin of the 'nid' field only has one source value, the $scalar is set to true. The count($destination_ids) returns 2 and thus nothing is returned.
So question, is this a bug, or do I need to configure the whole thing in a different matter??
Comment | File | Size | Author |
---|---|---|---|
#7 | core-migrate-translations-2809315-1.patch | 680 bytes | kriboogh |
Comments
Comment #2
kriboogh CreditAttribution: kriboogh at Calibrate commentedComment #3
kriboogh CreditAttribution: kriboogh at Calibrate commentedComment #4
kriboogh CreditAttribution: kriboogh at Calibrate commentedRemoving the extra check on the count makes the code work... so maybe someone can have a look at it to see why this check is necessary.
Comment #5
kriboogh CreditAttribution: kriboogh at Calibrate commentedComment #6
heddnMarking as a support request and leaving as active. There is not patch to review.
Comment #7
kriboogh CreditAttribution: kriboogh at Calibrate commentedHeres a patch agains the latest 8.2
Comment #8
heddnI think this is a duplicate of #2767643: Scalar to array migration returns NULL .