diff --git a/core/modules/migrate/config/schema/migrate.data_types.schema.yml b/core/modules/migrate/config/schema/migrate.data_types.schema.yml index 5b95871..e1b0231 100644 --- a/core/modules/migrate/config/schema/migrate.data_types.schema.yml +++ b/core/modules/migrate/config/schema/migrate.data_types.schema.yml @@ -24,7 +24,7 @@ migrate_source: migrate_source_sql: type: migrate_source mapping: - idlist: + id_list: type: sequence label: 'Source IDs to be migrated' target: diff --git a/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php index 332769c..e99c560 100644 --- a/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php +++ b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php @@ -139,6 +139,9 @@ // @TODO, find out how to remove this. // @see https://www.drupal.org/node/2443617 + /** + * @var \Drupal\migrate\MigrateExecutableInterface + */ public $migrateExecutable; /** @@ -194,8 +197,9 @@ protected function getModuleHandler() { */ protected function getIdList() { if (!empty($this->configuration['id_list'])) { - if (count($this->getIds()) > 1) { - throw new \LogicException('Cannot filter on multi-value key.'); + // @TODO: Add support for multiple IDs https://www.drupal.org/node/2529744 + if (count($this->getIds()) != 1) { + throw new \LogicException('Source IDs can only be specified by a list if there is only one id.'); } return $this->configuration['id_list']; } @@ -238,7 +242,7 @@ public function prepareRow(Row $row) { /** * Returns the iterator that will yield the row arrays to be processed. * - * @return \Iterator + * @return \Iterator|\Countable */ public function getIterator() { if (!isset($this->iterator)) { diff --git a/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php index 68700dc..cd8f606 100644 --- a/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php +++ b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php @@ -131,7 +131,7 @@ protected function initializeIterator() { $this->prepareQuery(); $high_water_property = $this->migration->get('highWaterProperty'); - if (empty($this->configuration['idlist'])) { + if (!$this->getIdList()) { // 1. If the map is joinable, join it. We will want to accept all rows // which are either not in the map, or marked in the map as NEEDS_UPDATE. // Note that if high water fields are in play, we want to accept all rows diff --git a/core/modules/migrate/tests/src/Unit/MigrateSourceTest.php b/core/modules/migrate/tests/src/Unit/MigrateSourceTest.php index d6e726a..6b73c66 100644 --- a/core/modules/migrate/tests/src/Unit/MigrateSourceTest.php +++ b/core/modules/migrate/tests/src/Unit/MigrateSourceTest.php @@ -93,7 +93,7 @@ protected function getSource($configuration = [], $migrate_config = [], $status $source_plugin ->expects($this->any()) ->method('getIds') - ->willReturn([]); + ->willReturn(['test_sourceid1' => []]); $source_plugin ->expects($this->any()) ->method('__toString') @@ -172,7 +172,8 @@ public function testPrepareRowFalse() { * Test that the when a source id is in the idList, we don't get a row. */ public function testIdInList() { - $source = $this->getSource([], ['idlist' => ['test_sourceid1']]); + $source = $this->getSource(['id_list' => ['test_sourceid1']]); + $source->rewind(); $this->assertNull($source->current(), 'No row is available because id was in idList.'); diff --git a/core/modules/migrate_drupal/tests/src/Unit/source/d6/NodeIdListTest.php b/core/modules/migrate_drupal/tests/src/Unit/source/d6/NodeIdListTest.php index 4e2afcb..b01e0cb 100644 --- a/core/modules/migrate_drupal/tests/src/Unit/source/d6/NodeIdListTest.php +++ b/core/modules/migrate_drupal/tests/src/Unit/source/d6/NodeIdListTest.php @@ -15,14 +15,14 @@ class NodeIdListTest extends NodeTest { // The fake Migration configuration entity. - protected $migrationConfiguration = array( + protected $migrationConfiguration = [ 'id' => 'test', // The fake configuration for the source. - 'source' => array( + 'source' => [ 'plugin' => 'd6_node', 'id_list' => [1], - ), - ); + ], + ]; /** * {@inheritdoc}