reverted: --- b/core/modules/migrate/config/schema/migrate.data_types.schema.yml +++ a/core/modules/migrate/config/schema/migrate.data_types.schema.yml @@ -24,9 +24,6 @@ migrate_source_sql: type: migrate_source mapping: - id_list: - type: sequence - label: 'Source IDs to be migrated' target: type: string label: 'The migration database target' 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 @@ -84,6 +84,14 @@ protected $originalHighWater; /** + * List of source IDs to process. Each ID in the list is an array of values, + * to support multi-value keys. + * + * @var array[] + */ + protected $idList = []; + + /** * Whether this instance should cache the source count. * * @var bool @@ -139,9 +147,6 @@ // @TODO, find out how to remove this. // @see https://www.drupal.org/node/2443617 - /** - * @var \Drupal\migrate\MigrateExecutableInterface - */ public $migrateExecutable; /** @@ -190,27 +195,16 @@ } /** - * Get the list of IDs of the rows to be migrated. - * - * @return array - * The list of IDs of the rows to be migrated. + * {@inheritdoc} */ - protected function getIdList() { - if (!empty($this->configuration['id_list'])) { - // @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']; - } - return []; + public function setIdList(array $id_list) { + $this->idList = $id_list; } /** * {@inheritdoc} */ public function prepareRow(Row $row) { - $result = TRUE; $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)); @@ -242,7 +236,7 @@ /** * Returns the iterator that will yield the row arrays to be processed. * - * @return \Iterator|\Countable + * @return \Iterator */ public function getIterator() { if (!isset($this->iterator)) { @@ -312,6 +306,7 @@ public function next() { $this->currentSourceIds = NULL; $this->currentRow = NULL; + $id_list = array_map('reset', $this->idList); // In order to find the next row we want to process, we ask the source // plugin for the next possible row. @@ -330,11 +325,11 @@ // In case we have specified an ID list, but the ID given by the source is // not in there, we skip the row. - $id_list = $this->getIdList(); $id_in_the_list = $id_list && in_array(reset($this->currentSourceIds), $id_list); if ($id_list && !$id_in_the_list) { continue; } + // Preparing the row gives source plugins the chance to skip. if ($this->prepareRow($row) === FALSE) { continue; diff -u b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php --- b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php +++ b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php @@ -117,15 +117,18 @@ $this->addQueryInfo(); // If an ID list is provided, filter on it. - if ($id_list = $this->getIdList()) { - foreach ($this->getIds() as $field => $definition) { - // If a table alias was provided, prepend it in order to prevent - // the possibility of 'ambiguous column' errors. - if (isset($definition['alias'])) { - $field = $definition['alias'] . '.' . $field; - } - $this->query->condition($field, $id_list, 'IN'); + if ($this->idList) { + // @TODO: Add support for multiple IDs https://www.drupal.org/node/2529744. + $id_info = $this->getIds(); + $field = key($id_info); + $definition = $id_info[$field]; + // If a table alias was provided, prepend it in order to prevent + // the possibility of 'ambiguous column' errors. + if (isset($definition['alias'])) { + $field = $definition['alias'] . '.' . $field; } + // For now, just use the first element of each ID array. + $this->query->condition($field, array_map('reset', $this->idList), 'IN'); } else { /** @var \Drupal\Core\Database\Query\Condition $conditions */ diff -u b/core/modules/migrate/tests/src/Unit/MigrateSourceTest.php b/core/modules/migrate/tests/src/Unit/MigrateSourceTest.php --- b/core/modules/migrate/tests/src/Unit/MigrateSourceTest.php +++ b/core/modules/migrate/tests/src/Unit/MigrateSourceTest.php @@ -172,7 +172,8 @@ * Test that the when a source id is in the idList, we don't get a row. */ public function testIdInList() { - $source = $this->getSource(['id_list' => ['test_sourceid1']]); + $source = $this->getSource(); + $source->setIdList([['test_sourceid1']]); $source->rewind(); only in patch2: unchanged: --- a/core/modules/migrate/src/Plugin/MigrateSourceInterface.php +++ b/core/modules/migrate/src/Plugin/MigrateSourceInterface.php @@ -62,4 +62,12 @@ public function __toString(); */ public function getIds(); + /** + * Set the list of source IDs to be processed. Each ID in the list is an + * array of key values (supporting multi-field keys). + * + * @param array[] $id_list + */ + public function setIdList(array $id_list); + }