Mercurial > hg > isophonics-drupal-site
diff core/modules/migrate/src/MigrateExecutable.php @ 18:af1871eacc83
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:33:08 +0100 |
parents | 129ea1e6d783 |
children |
line wrap: on
line diff
--- a/core/modules/migrate/src/MigrateExecutable.php Thu Feb 28 13:21:36 2019 +0000 +++ b/core/modules/migrate/src/MigrateExecutable.php Thu May 09 15:33:08 2019 +0100 @@ -105,7 +105,7 @@ public function __construct(MigrationInterface $migration, MigrateMessageInterface $message = NULL, EventDispatcherInterface $event_dispatcher = NULL) { $this->migration = $migration; $this->message = $message ?: new MigrateMessage(); - $this->migration->getIdMap()->setMessage($this->message); + $this->getIdMap()->setMessage($this->message); $this->eventDispatcher = $event_dispatcher; // Record the memory limit in bytes $limit = trim(ini_get('memory_limit')); @@ -182,7 +182,7 @@ $this->migration->setStatus(MigrationInterface::STATUS_IMPORTING); $return = MigrationInterface::RESULT_COMPLETED; $source = $this->getSource(); - $id_map = $this->migration->getIdMap(); + $id_map = $this->getIdMap(); try { $source->rewind(); @@ -204,7 +204,7 @@ $save = TRUE; } catch (MigrateException $e) { - $this->migration->getIdMap()->saveIdMapping($row, [], $e->getStatus()); + $this->getIdMap()->saveIdMapping($row, [], $e->getStatus()); $this->saveMessage($e->getMessage(), $e->getLevel()); $save = FALSE; } @@ -241,11 +241,11 @@ } } catch (MigrateException $e) { - $this->migration->getIdMap()->saveIdMapping($row, [], $e->getStatus()); + $this->getIdMap()->saveIdMapping($row, [], $e->getStatus()); $this->saveMessage($e->getMessage(), $e->getLevel()); } catch (\Exception $e) { - $this->migration->getIdMap()->saveIdMapping($row, [], MigrateIdMapInterface::STATUS_FAILED); + $this->getIdMap()->saveIdMapping($row, [], MigrateIdMapInterface::STATUS_FAILED); $this->handleException($e); } } @@ -299,11 +299,12 @@ $return = MigrationInterface::RESULT_COMPLETED; $this->migration->setStatus(MigrationInterface::STATUS_ROLLING_BACK); - $id_map = $this->migration->getIdMap(); + $id_map = $this->getIdMap(); $destination = $this->migration->getDestinationPlugin(); // Loop through each row in the map, and try to roll it back. - foreach ($id_map as $map_row) { + $id_map->rewind(); + while ($id_map->valid()) { $destination_key = $id_map->currentDestination(); if ($destination_key) { $map_row = $id_map->getRowByDestination($destination_key); @@ -323,6 +324,7 @@ $source_key = $id_map->currentSource(); $id_map->delete($source_key); } + $id_map->next(); // Check for memory exhaustion. if (($return = $this->checkStatus()) != MigrationInterface::RESULT_COMPLETED) { @@ -345,6 +347,16 @@ } /** + * Get the ID map from the current migration. + * + * @return \Drupal\migrate\Plugin\MigrateIdMapInterface + * The ID map. + */ + protected function getIdMap() { + return $this->migration->getIdMap(); + } + + /** * {@inheritdoc} */ public function processRow(Row $row, array $process = NULL, $value = NULL) { @@ -416,7 +428,7 @@ * {@inheritdoc} */ public function saveMessage($message, $level = MigrationInterface::MESSAGE_ERROR) { - $this->migration->getIdMap()->saveMessage($this->sourceIdValues, $message, $level); + $this->getIdMap()->saveMessage($this->sourceIdValues, $message, $level); } /**