diff -u b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php --- b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php +++ b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php @@ -182,11 +182,11 @@ * {@inheritdoc} */ public function prepareRow(Row $row) { - $result = TRUE; try { $result_hook = $this->getModuleHandler()->invokeAll('migrate_prepare_row', array($row, $this, $this->migration)); $result_named_hook = $this->getModuleHandler()->invokeAll('migrate_' . $this->migration->id() . '_prepare_row', array($row, $this, $this->migration)); + // We will skip if any hook returned FALSE. $skip = ($result_hook && in_array(FALSE, $result_hook)) || ($result_named_hook && in_array(FALSE, $result_named_hook)); $record_in_map = TRUE; } reverted: --- b/core/modules/migrate/tests/migrate_prepare_row_test/migrate_prepare_row_test.info.yml +++ /dev/null @@ -1,6 +0,0 @@ -name: 'Migrate module prepareRow tests' -type: module -description: 'Support module for source plugin prepareRow testing.' -package: Testing -version: VERSION -core: 8.x reverted: --- b/core/modules/migrate/tests/migrate_prepare_row_test/migrate_prepare_row_test.module +++ /dev/null @@ -1,29 +0,0 @@ -getSourceProperty('instruction'); - if ($instruction == 'skip_and_record') { - throw new MigrateSkipRowException('', TRUE); - } - elseif ($instruction == 'skip_and_dont_record') { - throw new MigrateSkipRowException('', FALSE); - } -} only in patch2: unchanged: --- /dev/null +++ b/core/modules/migrate/src/Tests/MigrateSkipRowTest.php @@ -0,0 +1,65 @@ + 'sample_data', + 'migration_tags' => ['prepare_row test'], + 'source' => ['plugin' => 'data'], + 'process' => ['value' => 'data'], + 'destination' => [ + 'plugin' => 'config', + 'config_name' => 'migrate_test.settings', + ], + 'load' => ['plugin' => 'null'], + ]; + + $migration = Migration::create($config); + + $executable = new MigrateExecutable($migration, new MigrateMessage); + $result = $executable->import(); + $this->assertEqual($result, MigrationInterface::RESULT_COMPLETED); + + $id_map_plugin = $migration->getIdMap(); + // The first row is recorded in the map as ignored. + $map_row = $id_map_plugin->getRowBySource([1]); + $this->assertEqual(MigrateIdMapInterface::STATUS_IGNORED, $map_row['source_row_status']); + // The second row is not recorded in the map. + $map_row = $id_map_plugin->getRowBySource([2]); + $this->assertFalse($map_row); + + } + +} only in patch2: unchanged: --- /dev/null +++ b/core/modules/migrate/tests/modules/migrate_prepare_row_test/migrate_prepare_row_test.info.yml @@ -0,0 +1,6 @@ +name: 'Migrate module prepareRow tests' +type: module +description: 'Support module for source plugin prepareRow testing.' +package: Testing +version: VERSION +core: 8.x only in patch2: unchanged: --- /dev/null +++ b/core/modules/migrate/tests/modules/migrate_prepare_row_test/migrate_prepare_row_test.module @@ -0,0 +1,26 @@ +getSourceProperty('data'); + if ($data == 'skip_and_record') { + throw new MigrateSkipRowException('', TRUE); + } + elseif ($data == 'skip_and_dont_record') { + throw new MigrateSkipRowException('', FALSE); + } +} only in patch2: unchanged: --- /dev/null +++ b/core/modules/migrate/tests/modules/migrate_prepare_row_test/src/Plugin/migrate/source/DataSource.php @@ -0,0 +1,59 @@ + t('Data'), + ); + } + + /** + * {@inheritdoc} + */ + public function initializeIterator() { + return new \ArrayIterator([ + ['id' => '1', 'data' => 'skip_and_record'], + ['id' => '2', 'data' => 'skip_and_dont_record'], + ]); + } + + public function __toString() { + return 'Sample data for testing'; + } + + /** + * {@inheritdoc} + */ + public function getIds() { + $ids['id']['type'] = 'string'; + return $ids; + } + + /** + * {@inheritdoc} + */ + public function count() { + return 2; + } + +}