Commit 72b1c2f1 authored by alexpott's avatar alexpott

Issue #2320245 by benjy | jhodgdon: Fixed High water should consistently be two words.

parent fb27c45f
......@@ -145,11 +145,11 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
public $destinationIds = FALSE;
/**
* Information on the highwater mark.
* Information on the high water mark.
*
* @var array
*/
public $highwaterProperty;
public $highWaterProperty;
/**
* Indicate whether the primary system of record for this migration is the
......@@ -174,7 +174,7 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
/**
* @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface
*/
protected $highwaterStorage;
protected $highWaterStorage;
/**
* @var bool
......@@ -282,30 +282,30 @@ public function getIdMap() {
}
/**
* Get the highwater storage object.
* Get the high water storage object.
*
* @return \Drupal\Core\KeyValueStore\KeyValueStoreInterface
* The storage object.
*/
protected function getHighWaterStorage() {
if (!isset($this->highwaterStorage)) {
$this->highwaterStorage = \Drupal::keyValue('migrate:highwater');
if (!isset($this->highWaterStorage)) {
$this->highWaterStorage = \Drupal::keyValue('migrate:high_water');
}
return $this->highwaterStorage;
return $this->highWaterStorage;
}
/**
* {@inheritdoc}
*/
public function getHighwater() {
public function getHighWater() {
return $this->getHighWaterStorage()->get($this->id());
}
/**
* {@inheritdoc}
*/
public function saveHighwater($highwater) {
$this->getHighWaterStorage()->set($this->id(), $highwater);
public function saveHighWater($high_water) {
$this->getHighWaterStorage()->set($this->id(), $high_water);
}
/**
......
......@@ -136,24 +136,24 @@ public function getDestinationPlugin();
public function getIdMap();
/**
* The current value of the highwater mark.
* The current value of the high water mark.
*
* The highwater mark defines a timestamp stating the time the import was last
* The high water mark defines a timestamp stating the time the import was last
* run. If the mark is set, only content with a higher timestamp will be
* imported.
*
* @return int
* A Unix timestamp representing the highwater mark.
* A Unix timestamp representing the high water mark.
*/
public function getHighwater();
public function getHighWater();
/**
* Save the new highwater mark.
* Save the new high water mark.
*
* @param int $highwater
* The highwater timestamp.
* @param int $high_water
* The high water timestamp.
*/
public function saveHighwater($highwater);
public function saveHighWater($high_water);
/**
* Check if this migration is complete.
......
......@@ -303,8 +303,8 @@ public function import() {
}
$this->totalProcessed++;
$this->processedSinceFeedback++;
if ($highwater_property = $this->migration->get('highwaterProperty')) {
$this->migration->saveHighwater($row->getSourceProperty($highwater_property['name']));
if ($high_water_property = $this->migration->get('highWaterProperty')) {
$this->migration->saveHighWater($row->getSourceProperty($high_water_property['name']));
}
// Reset row properties.
......
......@@ -93,7 +93,7 @@ protected function prepareQuery() {
*/
protected function runQuery() {
$this->prepareQuery();
$highwaterProperty = $this->migration->get('highwaterProperty');
$high_water_property = $this->migration->get('highWaterProperty');
// Get the key values, for potential use in joining to the map table, or
// enforcing idlist.
......@@ -109,12 +109,12 @@ protected function runQuery() {
else {
// 2. 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 highwater fields are in play, we want to accept all rows
// above the highwater mark in addition to those selected by the map
// Note that if high water fields are in play, we want to accept all rows
// above the high water mark in addition to those selected by the map
// conditions, so we need to OR them together (but AND with any existing
// conditions in the query). So, ultimately the SQL condition will look
// like (original conditions) AND (map IS NULL OR map needs update
// OR above highwater).
// OR above high water).
$conditions = $this->query->orConditionGroup();
$condition_added = FALSE;
if ($this->mapJoinable()) {
......@@ -149,16 +149,16 @@ protected function runQuery() {
}
$this->query->addField($alias, 'source_row_status', 'migrate_map_source_row_status');
}
// 3. If we are using highwater marks, also include rows above the mark.
// But, include all rows if the highwater mark is not set.
if (isset($highwaterProperty['name']) && ($highwater = $this->migration->getHighwater()) !== '') {
if (isset($highwaterProperty['alias'])) {
$highwater = $highwaterProperty['alias'] . '.' . $highwaterProperty['name'];
// 3. 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 (isset($high_water_property['name']) && ($high_water = $this->migration->getHighWater()) !== '') {
if (isset($high_water_property['alias'])) {
$high_water = $high_water_property['alias'] . '.' . $high_water_property['name'];
}
else {
$highwater = $highwaterProperty['name'];
$high_water = $high_water_property['name'];
}
$conditions->condition($highwater, $highwater, '>');
$conditions->condition($high_water, $high_water, '>');
$condition_added = TRUE;
}
if ($condition_added) {
......
......@@ -49,11 +49,11 @@ class Source implements \Iterator, \Countable {
protected $numProcessed = 0;
/**
* The highwater mark at the beginning of the import operation.
* The high water mark at the beginning of the import operation.
*
* @var
*/
protected $originalHighwater = '';
protected $originalHighWater = '';
/**
* List of source IDs to process.
......@@ -119,7 +119,7 @@ class Source implements \Iterator, \Countable {
/**
* @var array
*/
protected $highwaterProperty;
protected $highWaterProperty;
/**
* Getter for currentIds data member.
......@@ -286,8 +286,8 @@ public function rewind() {
$this->idMap = $this->migration->getIdMap();
$this->numProcessed = 0;
$this->numIgnored = 0;
$this->originalHighwater = $this->migration->getHighwater();
$this->highwaterProperty = $this->migration->get('highwaterProperty');
$this->originalHighWater = $this->migration->getHighWater();
$this->highWaterProperty = $this->migration->get('highWaterProperty');
if ($id_list = $this->migration->get('idlist')) {
$this->idList = $id_list;
}
......@@ -319,14 +319,14 @@ public function next() {
// First, determine if this row should be passed to prepareRow(), or
// skipped entirely. The rules are:
// 1. If there's an explicit idlist, that's all we care about (ignore
// highwaters and map rows).
// high waters and map rows).
$prepared = FALSE;
if (!empty($this->idList)) {
if (in_array(reset($this->currentIds), $this->idList)) {
// In the list, fall through.
}
else {
// Not in the list, skip it
// Not in the list, skip it.
continue;
}
}
......@@ -340,11 +340,11 @@ public function next() {
// Fall through.
}
// 4. At this point, we have a row which has previously been imported and
// not marked for update. If we're not using highwater marks, then we
// not marked for update. If we're not using high water marks, then we
// will not take this row. Except, if we're looking for changes in the
// data, we need to go through prepareRow() before we can decide to
// skip it.
elseif (!empty($highwater['field'])) {
elseif (!empty($this->highWaterProperty['field'])) {
if ($this->trackChanges) {
if ($this->prepareRow($row) !== FALSE) {
if ($row->changed()) {
......@@ -363,22 +363,22 @@ public function next() {
}
}
else {
// No highwater and not tracking changes, skip.
// No high water and not tracking changes, skip.
continue;
}
}
// 5. The initial highwater mark, before anything is migrated, is ''. We
// want to make sure we don't mistakenly skip rows with a highwater
// 5. The initial high water mark, before anything is migrated, is ''. We
// want to make sure we don't mistakenly skip rows with a high water
// field value of 0, so explicitly handle '' here.
elseif ($this->originalHighwater === '') {
elseif ($this->originalHighWater === '') {
// Fall through
}
// 6. So, we are using highwater marks. Take the row if its highwater
// 6. So, we are using high water marks. Take the row if its high water
// field value is greater than the saved mark, otherwise skip it.
else {
// Call prepareRow() here, in case the highwaterField needs preparation.
// Call prepareRow() here, in case the highWaterField needs preparation.
if ($this->prepareRow($row) !== FALSE) {
if ($row->getSourceProperty($this->highwaterProperty['name']) > $this->originalHighwater) {
if ($row->getSourceProperty($this->highWaterProperty['name']) > $this->originalHighWater) {
$this->currentRow = $row;
break;
}
......
......@@ -45,14 +45,14 @@ abstract class MigrateSqlSourceTestCase extends MigrateTestCase {
const PLUGIN_CLASS = '';
/**
* The highwater mark at the beginning of the import operation.
* The high water mark at the beginning of the import operation.
*
* Once the migration is run, we save a mark of the migrated sources, so the
* migration can run again and update only new sources or changed sources.
*
* @var string
*/
const ORIGINAL_HIGHWATER = '';
const ORIGINAL_HIGH_WATER = '';
/**
* Expected results after the source parsing.
......@@ -76,8 +76,8 @@ protected function setUp() {
$migration = $this->getMigration();
$migration->expects($this->any())
->method('getHighwater')
->will($this->returnValue(static::ORIGINAL_HIGHWATER));
->method('getHighWater')
->will($this->returnValue(static::ORIGINAL_HIGH_WATER));
// Need the test class, not the original because we need a setDatabase method. This is not pretty :/
$plugin_class = preg_replace('/^(Drupal\\\\\w+\\\\)Plugin\\\\migrate(\\\\source(\\\\.+)?\\\\)([^\\\\]+)$/', '\1Tests\2Test\4', static::PLUGIN_CLASS);
$plugin = new $plugin_class($this->migrationConfiguration['source'], $this->migrationConfiguration['source']['plugin'], array(), $migration);
......
......@@ -8,7 +8,7 @@
namespace Drupal\migrate_drupal\Tests\source;
/**
* Tests variable multirow source w/ highwater handling.
* Tests variable multirow source w/ high water handling.
*
* @group migrate_drupal
*/
......@@ -18,7 +18,7 @@ class VariableMultiRowSourceWithHighwaterTest extends VariableMultiRowTestBase {
* {@inheritdoc}
*/
protected function setUp() {
$this->migrationConfiguration['highwaterProperty']['field'] = 'test';
$this->migrationConfiguration['highWaterProperty']['field'] = 'test';
parent::setup();
}
......
......@@ -20,7 +20,7 @@ class VariableTest extends MigrateSqlSourceTestCase {
protected $migrationConfiguration = array(
'id' => 'test',
'highwaterProperty' => array('field' => 'test'),
'highWaterProperty' => array('field' => 'test'),
'idlist' => array(),
'source' => array(
'plugin' => 'd6_variable',
......
......@@ -2,25 +2,25 @@
/**
* @file
* Contains \Drupal\migrate_drupal\Tests\source\d6\CommentSourceWithHighwaterTest.
* Contains \Drupal\migrate_drupal\Tests\source\d6\CommentSourceWithHighWaterTest.
*/
namespace Drupal\migrate_drupal\Tests\source\d6;
/**
* Tests the Drupal 6 comment source w/ highwater handling.
* Tests the Drupal 6 comment source w/ high water handling.
*
* @group migrate_drupal
*/
class CommentSourceWithHighwaterTest extends CommentTestBase {
class CommentSourceWithHighWaterTest extends CommentTestBase {
const ORIGINAL_HIGHWATER = 1382255613;
const ORIGINAL_HIGH_WATER = 1382255613;
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->migrationConfiguration['highwaterProperty']['field'] = 'timestamp';
$this->migrationConfiguration['highWaterProperty']['field'] = 'timestamp';
array_shift($this->expectedResults);
parent::setUp();
}
......
......@@ -23,7 +23,7 @@ class FilterFormatTest extends MigrateSqlSourceTestCase {
// The fake Migration configuration entity.
protected $migrationConfiguration = array(
'id' => 'test',
'highwaterProperty' => array('field' => 'test'),
'highWaterProperty' => array('field' => 'test'),
'idlist' => array(),
'source' => array(
'plugin' => 'd6_filter_formats',
......
......@@ -18,7 +18,7 @@ abstract class TermTestBase extends MigrateSqlSourceTestCase {
protected $migrationConfiguration = array(
'id' => 'test',
'highwaterProperty' => array('field' => 'test'),
'highWaterProperty' => array('field' => 'test'),
'idlist' => array(),
'source' => array(
'plugin' => 'd6_taxonomy_term',
......
......@@ -20,7 +20,7 @@ class UrlAliasTest extends MigrateSqlSourceTestCase {
protected $migrationConfiguration = array(
'id' => 'test',
'highwaterProperty' => array('field' => 'test'),
'highWaterProperty' => array('field' => 'test'),
'idlist' => array(),
'source' => array(
'plugin' => 'd6_url_alias',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment