diff -u b/core/modules/migrate/src/MigrateExecutable.php b/core/modules/migrate/src/MigrateExecutable.php --- b/core/modules/migrate/src/MigrateExecutable.php +++ b/core/modules/migrate/src/MigrateExecutable.php @@ -261,6 +261,7 @@ catch (MigrateSkipRowException $e) { $id_map->saveIdMapping($row, array(), MigrateIdMapInterface::STATUS_IGNORED, $this->rollbackAction); $save = FALSE; + $this->incrementSkips(); } if ($save) { @@ -271,10 +272,11 @@ if ($destination_id_values !== TRUE) { $id_map->saveIdMapping($row, $destination_id_values, $this->sourceRowStatus, $this->rollbackAction); } - $this->counters->incrementSuccesses(); + $this->incrementSuccesses(); } else { $id_map->saveIdMapping($row, array(), MigrateIdMapInterface::STATUS_FAILED, $this->rollbackAction); + $this->incrementErrors(); if (!$id_map->messageCount()) { $message = $this->t('New object was not saved, no error provided'); $this->saveMessage($message); @@ -286,13 +288,15 @@ $this->migration->getIdMap()->saveIdMapping($row, array(), $e->getStatus(), $this->rollbackAction); $this->saveMessage($e->getMessage(), $e->getLevel()); $this->message->display($e->getMessage(), 'error'); + $this->incrementErrors(); } catch (\Exception $e) { $this->migration->getIdMap()->saveIdMapping($row, array(), MigrateIdMapInterface::STATUS_FAILED, $this->rollbackAction); $this->handleException($e); + $this->incrementErrors(); } } - $this->counters->incrementProcessed(); + $this->incrementProcessed(); if ($high_water_property = $this->migration->get('highWaterProperty')) { $this->migration->saveHighWater($row->getSourceProperty($high_water_property['name'])); } @@ -591,6 +595,34 @@ } /** + * {@inheritdoc} + */ + public function incrementSuccesses() { + $this->getCounters()->increment('successes'); + } + + /** + * {@inheritdoc} + */ + public function incrementProcessed() { + $this->getCounters()->increment('processed'); + } + + /** + * {@inheritdoc} + */ + public function incrementErrors() { + $this->getCounters()->increment('errors'); + } + + /** + * {@inheritdoc} + */ + public function incrementSkips() { + $this->getCounters()->increment('skips'); + } + + /** * Takes an Exception object and both saves and displays it. * * Pulls in additional information on the location triggering the exception. diff -u b/core/modules/migrate/src/MigrateExecutableInterface.php b/core/modules/migrate/src/MigrateExecutableInterface.php --- b/core/modules/migrate/src/MigrateExecutableInterface.php +++ b/core/modules/migrate/src/MigrateExecutableInterface.php @@ -52,6 +52,26 @@ public function getCounters(); /** + * Increments the 'successes' counter. + */ + public function incrementSuccesses(); + + /** + * Increments the 'processed' counter. + */ + public function incrementProcessed(); + + /** + * Increments the 'errors' counter. + */ + public function incrementErrors(); + + /** + * Increments the 'skips' counter. + */ + public function incrementSkips(); + + /** * Passes messages through to the map class. * * @param string $message diff -u b/core/modules/migrate/src/MigrationCounters.php b/core/modules/migrate/src/MigrationCounters.php --- b/core/modules/migrate/src/MigrationCounters.php +++ b/core/modules/migrate/src/MigrationCounters.php @@ -52,44 +52,2 @@ - /** - * {@inheritdoc} - */ - public function getSuccesses() { - return $this->get('successes'); - } - - /** - * {@inheritdoc} - */ - public function incrementSuccesses() { - $this->increment('successes'); - } - - /** - * {@inheritdoc} - */ - public function resetSuccesses() { - $this->reset('successes'); - } - - /** - * {@inheritdoc} - */ - public function getProcessed() { - return $this->get('processed'); - } - - /** - * {@inheritdoc} - */ - public function incrementProcessed() { - $this->increment('processed'); - } - - /** - * {@inheritdoc} - */ - public function resetProcessed() { - $this->reset('processed'); - } - } diff -u b/core/modules/migrate/src/MigrationCountersInterface.php b/core/modules/migrate/src/MigrationCountersInterface.php --- b/core/modules/migrate/src/MigrationCountersInterface.php +++ b/core/modules/migrate/src/MigrationCountersInterface.php @@ -42,37 +42,2 @@ - /** - * Returns the current success counter value. - * - * @return int - * The total number of successes, or 0 if no counter by this name exists. - */ - public function getSuccesses(); - - /** - * Increments the successes counter. - */ - public function incrementSuccesses(); - - /** - * Resets the successes counter to 0. - */ - public function resetSuccesses(); - - /** - * Returns the current processed counter value. - * - * @return int - * The total number processed, or 0 if no counter by this name exists. - */ - public function getProcessed(); - - /** - * Increments the processed counter. - */ - public function incrementProcessed(); - - /** - * Resets the processed counter to 0. - */ - public function resetProcessed(); - } + diff -u b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php --- b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php +++ b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php @@ -122,14 +122,11 @@ $this->assertSame(MigrationInterface::RESULT_COMPLETED, $this->executable->import()); $counters = $this->executable->getCounters(); - $this->assertSame(1, $counters->getSuccesses()); - $this->assertSame(1, $counters->getProcessed()); - - $counters->resetSuccesses(); - $this->assertSame(0, $counters->getSuccesses()); + $this->assertSame(1, $counters->get('successes')); + $this->assertSame(1, $counters->get('processed')); - $counters->resetProcessed(); - $this->assertSame(0, $counters->getProcessed()); + $counters->reset('successes'); + $this->assertSame(0, $counters->get('successes')); } /**