diff --git a/core/modules/migrate/src/Plugin/Migration.php b/core/modules/migrate/src/Plugin/Migration.php index 30fbf12..e7ff581 100644 --- a/core/modules/migrate/src/Plugin/Migration.php +++ b/core/modules/migrate/src/Plugin/Migration.php @@ -709,6 +709,18 @@ public function getHighWaterProperty() { /** * {@inheritdoc} */ + public function getHighWaterField() { + if (!empty($this->high_water_property['name'])) { + return !empty($this->high_water_property['alias']) ? + $this->high_water_property['alias'] . '.' . $this->high_water_property['name'] : + $this->high_water_property['name']; + } + return NULL; + } + + /** + * {@inheritdoc} + */ public function getTrackLastImported() { return $this->trackLastImported; } diff --git a/core/modules/migrate/src/Plugin/MigrationInterface.php b/core/modules/migrate/src/Plugin/MigrationInterface.php index 893c4c0..597f74d 100644 --- a/core/modules/migrate/src/Plugin/MigrationInterface.php +++ b/core/modules/migrate/src/Plugin/MigrationInterface.php @@ -357,6 +357,18 @@ public function getSourceConfiguration(); public function getHighWaterProperty(); /** + * Get the name of the field used as the high watermark. + * + * The name of the field qualified with an alias if available. + * + * @see Drupal\migrate\Plugin\migrate\source\SqlBase::initializeIterator() + * + * @return string|NULL + * The name of the field for the high water mark, or NULL if not set. + */ + public function getHighWaterField(); + + /** * If true, track time of last import. * * @return bool diff --git a/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php index 49287df..2065baa 100644 --- a/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php +++ b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php @@ -213,25 +213,16 @@ protected function initializeIterator() { // 2. If we are using high water marks, also include rows above the mark. // But, include all rows if the high water mark is not set. - if ($high_water_property = $this->migration->getHighWaterProperty()) { - if (isset($high_water_property['name'])) { - if (isset($high_water_property['alias'])) { - $high_water_field = $high_water_property['alias'] . '.' . $high_water_property['name']; - } - else { - $high_water_field = $high_water_property['name']; - } - - $this->query->orderBy($high_water_field); + if ($high_water_field = $this->migration->getHighWaterField()) { + $this->query->orderBy($high_water_field); - $high_water = $this->migration->getHighWater(); - if (!empty($high_water)) { - $conditions->condition($high_water_field, $high_water, '>'); - $condition_added = TRUE; - } - if ($condition_added) { - $this->query->condition($conditions); - } + $high_water = $this->migration->getHighWater(); + if (!empty($high_water)) { + $conditions->condition($high_water_field, $high_water, '>'); + $condition_added = TRUE; + } + if ($condition_added) { + $this->query->condition($conditions); } } return new \IteratorIterator($this->query->execute());