Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293248

Entity::getEntity() does not correctly deal with an existing ID mapping without a destination ID

$
0
0

Problem/Motivation

If you are doing a migration and have an error, then it saves an ID mapping without a destination ID.

When you repeat that row, then the destination receives array(0 => NULL) instead of array(). Personally, I think that's a bad API and I'm not sure what the use case is for supporting that as it leads to bugs like this.

The mentioned method does this:

<?php
$old_destination_id_values ? reset($old_destination_id_values) : $this->getEntityId($row);
?>

However, the first part is TRUE, sind the array is not empty, it has a NULL value. That result is that, depending on your migration, it's either silently creating a new entity and ignores the ID you passed in or fails with an error if there is no bundle key in $values.

Seems like a pretty fun way of killing your data, so setting to major.

Proposed resolution

Switch to reset($old_destination_id_values) ?: $this->getEntityId($row), so that it falls back to getting the ID from $row.

Remaining tasks

User interface changes

API changes

Data model changes


Viewing all articles
Browse latest Browse all 293248

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>