composer update
This commit is contained in:
parent
f6abc3dce2
commit
71dfaca858
1753 changed files with 45274 additions and 14619 deletions
|
@ -208,7 +208,14 @@ class MigrationPluginManager extends DefaultPluginManager implements MigrationPl
|
|||
$migration->set('requirements', $required_dependency_graph[$migration_id]['paths']);
|
||||
}
|
||||
}
|
||||
array_multisort($weights, SORT_DESC, SORT_NUMERIC, $migrations);
|
||||
// Sort weights, labels, and keys in the same order as each other.
|
||||
array_multisort(
|
||||
// Use the numerical weight as the primary sort.
|
||||
$weights, SORT_DESC, SORT_NUMERIC,
|
||||
// When migrations have the same weight, sort them alphabetically by ID.
|
||||
array_keys($migrations), SORT_ASC, SORT_NATURAL,
|
||||
$migrations
|
||||
);
|
||||
|
||||
return $migrations;
|
||||
}
|
||||
|
|
|
@ -584,7 +584,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
|
|||
|
||||
if (!empty($source_id_values)) {
|
||||
$var_dump = var_export($source_id_values, TRUE);
|
||||
throw new MigrateException(sprintf("Extra unknown items in source IDs: %s", $var_dump));
|
||||
throw new MigrateException(sprintf("Extra unknown items for map %s in source IDs: %s", $this->mapTableName(), $var_dump));
|
||||
}
|
||||
|
||||
$query = $this->getDatabase()->select($this->mapTableName(), 'map')
|
||||
|
|
|
@ -82,7 +82,8 @@ use Drupal\migrate\Row;
|
|||
* @endcode
|
||||
*
|
||||
* If the source value was '2004-12-19T10:19:42-0600' the transformed value
|
||||
* would be 2004-12-19T10:19:42.
|
||||
* would be 2004-12-19T10:19:42. Set validate_format to false if your source
|
||||
* value is '0000-00-00 00:00:00'.
|
||||
*
|
||||
* @see \DateTime::createFromFormat()
|
||||
* @see \Drupal\Component\Datetime\DateTimePlus::__construct()
|
||||
|
@ -99,7 +100,7 @@ class FormatDate extends ProcessPluginBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
if (empty($value)) {
|
||||
if (empty($value) && $value !== '0' && $value !== 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
|
|
@ -353,7 +353,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
|
|||
|
||||
$row_data = $this->getIterator()->current() + $this->configuration;
|
||||
$this->fetchNextRow();
|
||||
$row = new Row($row_data, $this->migration->getSourcePlugin()->getIds(), $this->migration->getDestinationIds());
|
||||
$row = new Row($row_data, $this->getIds());
|
||||
|
||||
// Populate the source key for this row.
|
||||
$this->currentSourceIds = $row->getSourceIdValues();
|
||||
|
|
|
@ -108,6 +108,11 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
|
|||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
|
||||
$this->state = $state;
|
||||
// If we are using high water, but haven't yet set a high water mark, skip
|
||||
// joining the map table, as we want to get all available records.
|
||||
if ($this->getHighWaterProperty() && $this->getHighWater() === NULL) {
|
||||
$this->configuration['ignore_map'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -322,7 +327,9 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
|
|||
if ($this->getHighWaterProperty()) {
|
||||
$high_water_field = $this->getHighWaterField();
|
||||
$high_water = $this->getHighWater();
|
||||
if ($high_water) {
|
||||
// We check against NULL because 0 is an acceptable value for the high
|
||||
// water mark.
|
||||
if ($high_water !== NULL) {
|
||||
$conditions->condition($high_water_field, $high_water, '>');
|
||||
$condition_added = TRUE;
|
||||
}
|
||||
|
|
|
@ -136,6 +136,72 @@ class HighWaterTest extends MigrateTestBase {
|
|||
$this->assertNodeDoesNotExist('Item 3');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the high water value can be 0.
|
||||
*/
|
||||
public function testZeroHighwater() {
|
||||
// Assert all of the nodes have been imported.
|
||||
$this->assertNodeExists('Item 1');
|
||||
$this->assertNodeExists('Item 2');
|
||||
$this->assertNodeExists('Item 3');
|
||||
$migration = $this->container->get('plugin.manager.migration')->CreateInstance('high_water_test', []);
|
||||
$source = $migration->getSourcePlugin();
|
||||
$source->rewind();
|
||||
$count = 0;
|
||||
while ($source->valid()) {
|
||||
$count++;
|
||||
$source->next();
|
||||
}
|
||||
|
||||
// Expect no rows as everything is below the high water mark.
|
||||
$this->assertSame(0, $count);
|
||||
|
||||
// Test resetting the high water mark to 0.
|
||||
$this->container->get('keyvalue')->get('migrate:high_water')->set('high_water_test', 0);
|
||||
$migration = $this->container->get('plugin.manager.migration')->CreateInstance('high_water_test', []);
|
||||
$source = $migration->getSourcePlugin();
|
||||
$source->rewind();
|
||||
$count = 0;
|
||||
while ($source->valid()) {
|
||||
$count++;
|
||||
$source->next();
|
||||
}
|
||||
$this->assertSame(3, $count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that deleting the high water value causes all rows to be reimported.
|
||||
*/
|
||||
public function testNullHighwater() {
|
||||
// Assert all of the nodes have been imported.
|
||||
$this->assertNodeExists('Item 1');
|
||||
$this->assertNodeExists('Item 2');
|
||||
$this->assertNodeExists('Item 3');
|
||||
$migration = $this->container->get('plugin.manager.migration')->CreateInstance('high_water_test', []);
|
||||
$source = $migration->getSourcePlugin();
|
||||
$source->rewind();
|
||||
$count = 0;
|
||||
while ($source->valid()) {
|
||||
$count++;
|
||||
$source->next();
|
||||
}
|
||||
|
||||
// Expect no rows as everything is below the high water mark.
|
||||
$this->assertSame(0, $count);
|
||||
|
||||
// Test resetting the high water mark.
|
||||
$this->container->get('keyvalue')->get('migrate:high_water')->delete('high_water_test');
|
||||
$migration = $this->container->get('plugin.manager.migration')->CreateInstance('high_water_test', []);
|
||||
$source = $migration->getSourcePlugin();
|
||||
$source->rewind();
|
||||
$count = 0;
|
||||
while ($source->valid()) {
|
||||
$count++;
|
||||
$source->next();
|
||||
}
|
||||
$this->assertSame(3, $count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests high water property of SqlBase when rows marked for update.
|
||||
*/
|
||||
|
|
|
@ -45,6 +45,11 @@ class MigrateEmbeddedDataTest extends KernelTestBase {
|
|||
$results = [];
|
||||
/** @var \Drupal\migrate\Row $row */
|
||||
foreach ($source as $row) {
|
||||
// The plugin should not mark any rows as stubs. We need to use
|
||||
// assertSame() here because assertFalse() will pass falsy values (e.g.,
|
||||
// empty arrays).
|
||||
$this->assertSame(FALSE, $row->isStub());
|
||||
|
||||
$data_row = $row->getSource();
|
||||
// The "data" row returned by getSource() also includes all source
|
||||
// configuration - we remove it so we see only the data itself.
|
||||
|
|
|
@ -529,14 +529,14 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
|
|||
$this->fail('Too many source IDs should throw');
|
||||
}
|
||||
catch (MigrateException $e) {
|
||||
$this->assertEquals("Extra unknown items in source IDs: array (\n 0 => 3,\n)", $e->getMessage());
|
||||
$this->assertEquals("Extra unknown items for map migrate_map_sql_idmap_test in source IDs: array (\n 0 => 3,\n)", $e->getMessage());
|
||||
}
|
||||
try {
|
||||
$id_map->lookupDestinationIds(['nid' => 1, 'aaa' => '2']);
|
||||
$this->fail('Unknown source ID key should throw');
|
||||
}
|
||||
catch (MigrateException $e) {
|
||||
$this->assertEquals("Extra unknown items in source IDs: array (\n 'aaa' => '2',\n)", $e->getMessage());
|
||||
$this->assertEquals("Extra unknown items for map migrate_map_sql_idmap_test in source IDs: array (\n 'aaa' => '2',\n)", $e->getMessage());
|
||||
}
|
||||
|
||||
// Verify that we are looking up by source_id_hash when all source IDs are
|
||||
|
|
|
@ -175,6 +175,42 @@ class FormatDateTest extends MigrateProcessTestCase {
|
|||
// converted from Australia/Sydney to America/Managua timezone.
|
||||
'expected' => '2004-12-18 17:19:42 America/Managua',
|
||||
],
|
||||
'integer_0' => [
|
||||
'configuration' => [
|
||||
'from_format' => 'U',
|
||||
'to_format' => 'Y-m-d',
|
||||
],
|
||||
'value' => 0,
|
||||
'expected' => '1970-01-01',
|
||||
],
|
||||
'string_0' => [
|
||||
'configuration' => [
|
||||
'from_format' => 'U',
|
||||
'to_format' => 'Y-m-d',
|
||||
],
|
||||
'value' => '0',
|
||||
'expected' => '1970-01-01',
|
||||
],
|
||||
'zeros' => [
|
||||
'configuration' => [
|
||||
'from_format' => 'Y-m-d H:i:s',
|
||||
'to_format' => 'Y-m-d H:i:s e',
|
||||
'settings' => ['validate_format' => FALSE],
|
||||
],
|
||||
'value' => '0000-00-00 00:00:00',
|
||||
'expected' => '-0001-11-30 00:00:00 Australia/Sydney',
|
||||
],
|
||||
'zeros_same_timezone' => [
|
||||
'configuration' => [
|
||||
'from_format' => 'Y-m-d H:i:s',
|
||||
'to_format' => 'Y-m-d H:i:s',
|
||||
'settings' => ['validate_format' => FALSE],
|
||||
'from_timezone' => 'UTC',
|
||||
'to_timezone' => 'UTC',
|
||||
],
|
||||
'value' => '0000-00-00 00:00:00',
|
||||
'expected' => '-0001-11-30 00:00:00',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue