Issue #3439369 by fromme, quietone, pradhumanjain2311, smustgrave, alexpott: Remove deprecated code in migration system
parent
7f4b5f187a
commit
166f3a39e4
|
@ -194,18 +194,6 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
|
|||
*/
|
||||
protected $sourceRowStatus = MigrateIdMapInterface::STATUS_IMPORTED;
|
||||
|
||||
/**
|
||||
* Track time of last import if TRUE.
|
||||
*
|
||||
* @var bool
|
||||
*
|
||||
* @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no
|
||||
* replacement.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3282894
|
||||
*/
|
||||
protected $trackLastImported = FALSE;
|
||||
|
||||
/**
|
||||
* These migrations must be already executed before this migration can run.
|
||||
*
|
||||
|
@ -334,14 +322,7 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
|
|||
$this->$key = $value;
|
||||
}
|
||||
|
||||
if (isset($plugin_definition['trackLastImported'])) {
|
||||
@trigger_error("The key 'trackLastImported' is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3282894", E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
$this->migration_dependencies = ($this->migration_dependencies ?: []) + ['required' => [], 'optional' => []];
|
||||
if (count($this->migration_dependencies) !== 2 || !is_array($this->migration_dependencies['required']) || !is_array($this->migration_dependencies['optional'])) {
|
||||
@trigger_error("Invalid migration dependencies for {$this->id()} is deprecated in drupal:10.1.0 and will cause an error in drupal:11.0.0. See https://www.drupal.org/node/3266691", E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -607,9 +588,6 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
|
|||
}
|
||||
elseif ($property_name === 'migration_dependencies') {
|
||||
$value = ($value ?: []) + ['required' => [], 'optional' => []];
|
||||
if (count($value) !== 2 || !is_array($value['required']) || !is_array($value['optional'])) {
|
||||
@trigger_error("Invalid migration dependencies for {$this->id()} is deprecated in drupal:10.1.0 and will cause an error in drupal:11.0.0. See https://www.drupal.org/node/3266691", E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
$this->{$property_name} = $value;
|
||||
return $this;
|
||||
|
@ -655,47 +633,23 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isTrackLastImported() {
|
||||
@trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3282894', E_USER_DEPRECATED);
|
||||
return $this->trackLastImported;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setTrackLastImported($track_last_imported) {
|
||||
@trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3282894', E_USER_DEPRECATED);
|
||||
$this->trackLastImported = (bool) $track_last_imported;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the dependencies for this migration.
|
||||
*
|
||||
* @param bool $expand
|
||||
* Will issue a deprecation in Drupal 10 if set to FALSE. See
|
||||
* https://www.drupal.org/node/3266691.
|
||||
*
|
||||
* @return array
|
||||
* The dependencies for this migrations.
|
||||
* The dependencies for this migration.
|
||||
*/
|
||||
public function getMigrationDependencies(bool $expand = FALSE) {
|
||||
if (!$expand) {
|
||||
@trigger_error('Calling Migration::getMigrationDependencies() without expanding the plugin IDs is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. In most cases, use getMigrationDependencies(TRUE). See https://www.drupal.org/node/3266691', E_USER_DEPRECATED);
|
||||
public function getMigrationDependencies() {
|
||||
if (func_num_args() > 0) {
|
||||
@trigger_error('Calling ' . __METHOD__ . ' with the $expand parameter is deprecated in drupal:11.0.0 and is removed drupal:12.0.0. See https://www.drupal.org/node/3442785', E_USER_DEPRECATED);
|
||||
}
|
||||
// @todo Before Drupal 11.0.0, remove ::set() and these checks.
|
||||
// @see https://www.drupal.org/project/drupal/issues/3262395
|
||||
|
||||
$this->migration_dependencies = ($this->migration_dependencies ?: []) + ['required' => [], 'optional' => []];
|
||||
if (count($this->migration_dependencies) !== 2 || !is_array($this->migration_dependencies['required']) || !is_array($this->migration_dependencies['optional'])) {
|
||||
throw new InvalidPluginDefinitionException($this->id(), "Invalid migration dependencies configuration for migration {$this->id()}");
|
||||
}
|
||||
$this->migration_dependencies['optional'] = array_unique(array_merge($this->migration_dependencies['optional'], $this->findMigrationDependencies($this->process)));
|
||||
if (!$expand) {
|
||||
return $this->migration_dependencies;
|
||||
}
|
||||
|
||||
return array_map(
|
||||
[$this->migrationPluginManager, 'expandPluginIds'],
|
||||
$this->migration_dependencies
|
||||
|
@ -762,14 +716,6 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
|
|||
return $this->source;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getTrackLastImported() {
|
||||
@trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3282894', E_USER_DEPRECATED);
|
||||
return $this->trackLastImported;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
@ -256,34 +256,6 @@ interface MigrationInterface extends PluginInspectionInterface, DerivativeInspec
|
|||
*/
|
||||
public function mergeProcessOfProperty($property, array $process_of_property);
|
||||
|
||||
/**
|
||||
* Checks if the migration should track time of last import.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the migration is tracking last import time.
|
||||
*
|
||||
* @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no
|
||||
* replacement.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3282894
|
||||
*/
|
||||
public function isTrackLastImported();
|
||||
|
||||
/**
|
||||
* Set if the migration should track time of last import.
|
||||
*
|
||||
* @param bool $track_last_imported
|
||||
* Boolean value to indicate if the migration should track last import time.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no
|
||||
* replacement.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3282894
|
||||
*/
|
||||
public function setTrackLastImported($track_last_imported);
|
||||
|
||||
/**
|
||||
* Get the dependencies for this migration.
|
||||
*
|
||||
|
@ -308,19 +280,6 @@ interface MigrationInterface extends PluginInspectionInterface, DerivativeInspec
|
|||
*/
|
||||
public function getSourceConfiguration();
|
||||
|
||||
/**
|
||||
* If true, track time of last import.
|
||||
*
|
||||
* @return bool
|
||||
* Flag to determine desire of tracking time of last import.
|
||||
*
|
||||
* @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no
|
||||
* replacement.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3282894
|
||||
*/
|
||||
public function getTrackLastImported();
|
||||
|
||||
/**
|
||||
* The destination identifiers.
|
||||
*
|
||||
|
|
|
@ -121,7 +121,7 @@ class MigrationPluginManager extends DefaultPluginManager implements MigrationPl
|
|||
// @todo Remove loop when the ability to call ::getMigrationDependencies()
|
||||
// without expanding plugins is removed.
|
||||
foreach ($instances as $migration) {
|
||||
$migration->set('migration_dependencies', $migration->getMigrationDependencies(TRUE));
|
||||
$migration->set('migration_dependencies', $migration->getMigrationDependencies());
|
||||
}
|
||||
|
||||
// Sort the migrations based on their dependencies.
|
||||
|
@ -169,7 +169,7 @@ class MigrationPluginManager extends DefaultPluginManager implements MigrationPl
|
|||
$id = $migration->id();
|
||||
$requirements[$id] = [];
|
||||
$dependency_graph[$id]['edges'] = [];
|
||||
$migration_dependencies = $migration->getMigrationDependencies(TRUE);
|
||||
$migration_dependencies = $migration->getMigrationDependencies();
|
||||
|
||||
if (isset($migration_dependencies['required'])) {
|
||||
foreach ($migration_dependencies['required'] as $dependency) {
|
||||
|
|
|
@ -187,11 +187,6 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
|
|||
$this->mapTableName = mb_substr($this->mapTableName, 0, 63 - $prefix_length);
|
||||
$this->messageTableName = 'migrate_message_' . mb_strtolower($machine_name);
|
||||
$this->messageTableName = mb_substr($this->messageTableName, 0, 63 - $prefix_length);
|
||||
|
||||
if (!$migration_plugin_manager) {
|
||||
@trigger_error('Calling Sql::__construct() without the $migration_manager argument is deprecated in drupal:9.5.0 and the $migration_manager argument will be required in drupal:11.0.0. See https://www.drupal.org/node/3277306', E_USER_DEPRECATED);
|
||||
$migration_plugin_manager = \Drupal::service('plugin.manager.migration');
|
||||
}
|
||||
$this->migrationPluginManager = $migration_plugin_manager;
|
||||
}
|
||||
|
||||
|
@ -1011,22 +1006,6 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
|
|||
return $this->currentRow !== FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the migration plugin manager.
|
||||
*
|
||||
* @return \Drupal\migrate\Plugin\MigrationPluginManagerInterface
|
||||
* The migration plugin manager.
|
||||
*
|
||||
* @deprecated in drupal:9.5.0 and is removed from drupal:11.0.0. Use
|
||||
* $this->migrationPluginManager instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3277306
|
||||
*/
|
||||
protected function getMigrationPluginManager() {
|
||||
@trigger_error(__METHOD__ . '() is deprecated in drupal:9.5.0 and is removed from drupal:11.0.0. Use $this->migrationPluginManager instead. See https://www.drupal.org/node/3277306', E_USER_DEPRECATED);
|
||||
return $this->migrationPluginManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
@ -154,7 +154,7 @@ class MigrationTest extends KernelTestBase {
|
|||
],
|
||||
];
|
||||
$migration = $plugin_manager->createStubMigration($plugin_definition);
|
||||
$this->assertSame(['required' => [], 'optional' => ['m1', 'm2', 'm3', 'm4', 'm5']], $migration->getMigrationDependencies(TRUE));
|
||||
$this->assertSame(['required' => [], 'optional' => ['m1', 'm2', 'm3', 'm4', 'm5']], $migration->getMigrationDependencies());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -169,24 +169,6 @@ class MigrationTest extends KernelTestBase {
|
|||
$this->assertEquals(['foo' => 'bar'], $destination_ids, 'Destination ids match the expected values.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Migration::getTrackLastImported()
|
||||
*
|
||||
* @covers ::getTrackLastImported
|
||||
* @covers ::isTrackLastImported
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
public function testGetTrackLastImported() {
|
||||
$this->expectDeprecation('Drupal\migrate\Plugin\Migration::setTrackLastImported() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3282894');
|
||||
$this->expectDeprecation('Drupal\migrate\Plugin\Migration::getTrackLastImported() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3282894');
|
||||
$this->expectDeprecation('Drupal\migrate\Plugin\Migration::isTrackLastImported() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3282894');
|
||||
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration([]);
|
||||
$migration->setTrackLastImported(TRUE);
|
||||
$this->assertEquals(TRUE, $migration->getTrackLastImported());
|
||||
$this->assertEquals(TRUE, $migration->isTrackLastImported());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Migration::getDestinationPlugin()
|
||||
*
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\Tests\migrate\Kernel\Plugin\id_map;
|
||||
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\migrate\Plugin\migrate\id_map\Sql;
|
||||
|
||||
/**
|
||||
* Tests deprecation notice in Sql constructor.
|
||||
*
|
||||
* @group migrate
|
||||
* @group legacy
|
||||
*/
|
||||
class SqlDeprecationTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $modules = ['migrate'];
|
||||
|
||||
/**
|
||||
* @covers \Drupal\migrate\Plugin\migrate\id_map\Sql::__construct
|
||||
*/
|
||||
public function testOptionalParametersDeprecation(): void {
|
||||
$migration = $this->prophesize('\Drupal\migrate\Plugin\MigrationInterface')->reveal();
|
||||
$this->expectDeprecation('Calling Sql::__construct() without the $migration_manager argument is deprecated in drupal:9.5.0 and the $migration_manager argument will be required in drupal:11.0.0. See https://www.drupal.org/node/3277306');
|
||||
new Sql(
|
||||
[],
|
||||
'sql',
|
||||
[],
|
||||
$migration,
|
||||
$this->container->get('event_dispatcher')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -4,9 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Drupal\Tests\migrate\Unit;
|
||||
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\sqlite\Driver\Database\sqlite\Connection;
|
||||
use Drupal\migrate\Plugin\MigrationPluginManager;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate\MigrateException;
|
||||
use Drupal\migrate\Plugin\MigrateIdMapInterface;
|
||||
|
@ -1219,20 +1217,4 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests deprecation message from Sql::getMigrationPluginManager().
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
public function testGetMigrationPluginManagerDeprecation() {
|
||||
$container = new ContainerBuilder();
|
||||
$migration_plugin_manager = $this->createMock(MigrationPluginManager::class);
|
||||
$container->set('plugin.manager.migration', $migration_plugin_manager);
|
||||
\Drupal::setContainer($container);
|
||||
|
||||
$this->expectDeprecation('Drupal\migrate\Plugin\migrate\id_map\Sql::getMigrationPluginManager() is deprecated in drupal:9.5.0 and is removed from drupal:11.0.0. Use $this->migrationPluginManager instead. See https://www.drupal.org/node/3277306');
|
||||
$id_map = $this->getIdMap();
|
||||
$id_map->getMigrationPluginManager();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -228,7 +228,7 @@ class TestMigrationMock extends Migration {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getMigrationDependencies(bool $expand = FALSE) {
|
||||
public function getMigrationDependencies() {
|
||||
// For the purpose of testing, do not expand dependencies.
|
||||
return $this->migration_dependencies;
|
||||
}
|
||||
|
|
|
@ -5,9 +5,6 @@ declare(strict_types=1);
|
|||
namespace Drupal\Tests\migrate\Unit;
|
||||
|
||||
use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException;
|
||||
use Drupal\migrate\Plugin\MigrateDestinationPluginManager;
|
||||
use Drupal\migrate\Plugin\MigratePluginManagerInterface;
|
||||
use Drupal\migrate\Plugin\MigrateSourcePluginManager;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\Migration;
|
||||
use Drupal\migrate\Exception\RequirementsException;
|
||||
|
@ -46,7 +43,6 @@ class MigrationTest extends UnitTestCase {
|
|||
$destination_plugin_manager = $this->createMock('\Drupal\migrate\Plugin\MigrateDestinationPluginManager');
|
||||
$id_map_plugin_manager = $this->createMock('\Drupal\migrate\Plugin\MigratePluginManagerInterface');
|
||||
|
||||
$this->expectDeprecation("Invalid migration dependencies for {$plugin_id} is deprecated in drupal:10.1.0 and will cause an error in drupal:11.0.0. See https://www.drupal.org/node/3266691");
|
||||
new Migration($configuration, $plugin_id, [], $migration_plugin_manager, $source_plugin_manager, $process_plugin_manager, $destination_plugin_manager, $id_map_plugin_manager);
|
||||
}
|
||||
|
||||
|
@ -178,7 +174,7 @@ class MigrationTest extends UnitTestCase {
|
|||
if (!is_null($source)) {
|
||||
$migration->set('migration_dependencies', $source);
|
||||
}
|
||||
$this->assertSame($migration->getMigrationDependencies(TRUE), $expected_value);
|
||||
$this->assertSame($migration->getMigrationDependencies(), $expected_value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -201,12 +197,11 @@ class MigrationTest extends UnitTestCase {
|
|||
$migration->setPluginId($plugin_id);
|
||||
|
||||
// Migration dependencies expects ['optional' => []] or ['required' => []]].
|
||||
$this->expectDeprecation("Invalid migration dependencies for {$plugin_id} is deprecated in drupal:10.1.0 and will cause an error in drupal:11.0.0. See https://www.drupal.org/node/3266691");
|
||||
$migration->set('migration_dependencies', $dependencies);
|
||||
|
||||
$this->expectException(InvalidPluginDefinitionException::class);
|
||||
$this->expectExceptionMessage("Invalid migration dependencies configuration for migration {$plugin_id}");
|
||||
$migration->getMigrationDependencies(TRUE);
|
||||
$migration->getMigrationDependencies();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -254,32 +249,6 @@ class MigrationTest extends UnitTestCase {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test trackLastImported deprecation message in Migration constructor.
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
public function testTrackLastImportedDeprecation() {
|
||||
$this->expectDeprecation("The key 'trackLastImported' is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3282894");
|
||||
$migration_plugin_manager = $this->createMock(MigrationPluginManagerInterface::class);
|
||||
$source_plugin_manager = $this->createMock(MigrateSourcePluginManager::class);
|
||||
$process_Plugin_manager = $this->createMock(MigratePluginManagerInterface::class);
|
||||
$destination_plugin_manager = $this->createMock(MigrateDestinationPluginManager::class);
|
||||
$id_map_plugin_manager = $this->createMock(MigratePluginManagerInterface::class);
|
||||
new Migration([], 'test', ['trackLastImported' => TRUE], $migration_plugin_manager, $source_plugin_manager, $process_Plugin_manager, $destination_plugin_manager, $id_map_plugin_manager);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests deprecation of getMigrationDependencies(FALSE).
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
public function testGetMigrationDependencies() {
|
||||
$migration = new TestMigration();
|
||||
$this->expectDeprecation('Calling Migration::getMigrationDependencies() without expanding the plugin IDs is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. In most cases, use getMigrationDependencies(TRUE). See https://www.drupal.org/node/3266691');
|
||||
$migration->getMigrationDependencies();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -93,11 +93,4 @@ class TestSqlIdMap extends Sql implements \Iterator {
|
|||
parent::ensureTables();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getMigrationPluginManager() {
|
||||
return parent::getMigrationPluginManager();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ abstract class ReferenceBase extends FieldPluginBase {
|
|||
parent::alterFieldInstanceMigration($migration);
|
||||
|
||||
// Add the reference migration as a required dependency to this migration.
|
||||
$migration_dependencies = $migration->getMigrationDependencies(TRUE);
|
||||
$migration_dependencies = $migration->getMigrationDependencies();
|
||||
array_push($migration_dependencies['required'], $this->getEntityTypeMigrationId());
|
||||
$migration_dependencies['required'] = array_unique($migration_dependencies['required']);
|
||||
$migration->set('migration_dependencies', $migration_dependencies);
|
||||
|
|
Loading…
Reference in New Issue