diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityContentMaster.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentMaster.php index 8be2cb9ed7..8ff14710a3 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/EntityContentMaster.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentMaster.php @@ -63,28 +63,22 @@ protected function getEntity(Row $row, array $old_destination_id_values) { $revision_id = $old_destination_id_values ? $old_destination_id_values[1] : $row->getDestinationProperty($this->getKey('revision')); - if (!empty($revision_id) && ($entity = $this->storage->loadRevision($revision_id))) { - $entity->setNewRevision(FALSE); + if (($entity_id = $row->getDestinationProperty($this->getKey('id'))) && + ($entity = $this->storage->load($entity_id))) { + $entity->enforceIsNew(FALSE); + $entity->setNewRevision(TRUE); } else { - if (($entity_id = $row->getDestinationProperty($this->getKey('id'))) && - ($entity = $this->storage->load($entity_id))) { - $entity->enforceIsNew(FALSE); - $entity->setNewRevision(TRUE); + // Attempt to ensure we always have a bundle. + if ($bundle = $this->getBundle($row)) { + $row->setDestinationProperty($this->getKey('bundle'), $bundle); } - else { - // Attempt to ensure we always have a bundle. - if ($bundle = $this->getBundle($row)) { - $row->setDestinationProperty($this->getKey('bundle'), $bundle); - } - - // Stubs might need some required fields filled in. - if ($row->isStub()) { - $this->processStubRow($row); - } - $entity = $this->storage->create($row->getDestination()); - $entity->enforceIsNew(); + // Stubs might need some required fields filled in. + if ($row->isStub()) { + $this->processStubRow($row); } + $entity = $this->storage->create($row->getDestination()); + $entity->enforceIsNew(); } // We need to update the entity, so that the destination row IDs are // correct.