--- 2791041-34.patch	2017-01-31 16:25:52.000000000 +0530
+++ 2791041-49.patch	2022-05-23 20:08:30.000000000 +0530
@@ -1,27 +1,17 @@
 diff --git a/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php b/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php
-index 05be56d..50a8a5c 100644
+index 158b3a8..fd26d02 100644
 --- a/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php
 +++ b/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php
-@@ -1,11 +1,17 @@
- <?php
+@@ -2,8 +2,6 @@
  
  namespace Drupal\migrate\Plugin\migrate\source;
--use Drupal\migrate\Plugin\MigrationInterface;
  
+-use Drupal\migrate\Plugin\MigrationInterface;
+-
  /**
-  * Source which takes its data directly from the plugin config.
+  * Allows source data to be defined in the configuration of the source plugin.
   *
-+ * Available configuration keys:
-+ * - data_rows: Array of data rows, each one an array of values keyed by
-+ *   field names.
-+ * - ids: Array describing the unique ID fields for the source data, keyed
-+ *   by the field names. Each array member is an array with a single 'type'
-+ *   key, which must be a column type such as 'integer'.
-+ *
-  * @MigrateSource(
-  *   id = "embedded_data"
-  * )
-@@ -13,38 +19,11 @@
+@@ -49,38 +47,11 @@
  class EmbeddedDataSource extends SourcePluginBase {
  
    /**
@@ -61,7 +51,7 @@
        $field_names = array_keys($first_row);
        return array_combine($field_names, $field_names);
      }
-@@ -57,7 +36,7 @@ public function fields() {
+@@ -93,7 +64,7 @@ public function fields() {
     * {@inheritdoc}
     */
    public function initializeIterator() {
@@ -70,7 +60,7 @@
    }
  
    /**
-@@ -71,14 +50,14 @@ public function __toString() {
+@@ -107,7 +78,7 @@ public function __toString() {
     * {@inheritdoc}
     */
    public function getIds() {
@@ -79,16 +69,17 @@
    }
  
    /**
-    * {@inheritdoc}
-    */
-   public function count() {
+@@ -117,7 +88,7 @@ public function getIds() {
+   public function count($refresh = FALSE) {
+     // We do not want this source plugin to have a cacheable count.
+     // @see \Drupal\migrate_cache_counts_test\Plugin\migrate\source\CacheableEmbeddedDataSource
 -    return count($this->dataRows);
 +    return count($this->configuration['data_rows']);
    }
  
  }
 diff --git a/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php
-index 5ce5fd3..127c846 100644
+index a3925d5..290c50a 100644
 --- a/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php
 +++ b/core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php
 @@ -2,6 +2,9 @@
@@ -98,18 +89,18 @@
 +use Drupal\Core\Cache\CacheBackendInterface;
 +use Drupal\Core\Extension\ModuleHandlerInterface;
 +use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+ use Drupal\Component\Serialization\Json;
  use Drupal\Core\Plugin\PluginBase;
  use Drupal\migrate\Event\MigrateRollbackEvent;
- use Drupal\migrate\Event\RollbackAwareInterface;
-@@ -11,6 +14,7 @@
+@@ -12,6 +15,7 @@
  use Drupal\migrate\Plugin\MigrateIdMapInterface;
  use Drupal\migrate\Plugin\MigrateSourceInterface;
  use Drupal\migrate\Row;
 +use Symfony\Component\DependencyInjection\ContainerInterface;
  
  /**
-  * The base class for all source plugins.
-@@ -22,7 +26,7 @@
+  * The base class for source plugins.
+@@ -114,7 +118,7 @@
   *
   * @ingroup migration
   */
@@ -118,7 +109,7 @@
  
    /**
     * The module handler service.
-@@ -146,7 +150,7 @@
+@@ -238,7 +242,7 @@
    /**
     * {@inheritdoc}
     */
@@ -127,9 +118,9 @@
      parent::__construct($configuration, $plugin_id, $plugin_definition);
      $this->migration = $migration;
  
-@@ -169,6 +173,24 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
+@@ -263,6 +267,24 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
      if ($this->highWaterProperty && $this->trackChanges) {
-       throw new MigrateException('You should either use a highwater mark or track changes not both. They are both designed to solve the same problem');
+       throw new MigrateException('You should either use a high-water mark or track changes not both. They are both designed to solve the same problem');
      }
 +
 +    $this->moduleHandler = $module_handler;
@@ -152,8 +143,8 @@
    }
  
    /**
-@@ -180,26 +202,13 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
-   protected abstract function initializeIterator();
+@@ -274,26 +296,13 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
+   abstract protected function initializeIterator();
  
    /**
 -   * Gets the module handler.
@@ -174,34 +165,28 @@
    public function prepareRow(Row $row) {
      $result = TRUE;
      try {
--      $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));
+-      $result_hook = $this->getModuleHandler()->invokeAll('migrate_prepare_row', [$row, $this, $this->migration]);
+-      $result_named_hook = $this->getModuleHandler()->invokeAll('migrate_' . $this->migration->id() . '_prepare_row', [$row, $this, $this->migration]);
 +      $result_hook = $this->moduleHandler->invokeAll('migrate_prepare_row', array($row, $this, $this->migration));
 +      $result_named_hook = $this->moduleHandler->invokeAll('migrate_' . $this->migration->id() . '_prepare_row', array($row, $this, $this->migration));
        // We will skip if any hook returned FALSE.
        $skip = ($result_hook && in_array(FALSE, $result_hook)) || ($result_named_hook && in_array(FALSE, $result_named_hook));
        $save_to_map = TRUE;
-@@ -412,11 +421,11 @@ public function count($refresh = FALSE) {
-     // class to get the count from the source.
-     if ($refresh || !$this->cacheCounts) {
-       $count = $this->doCount();
--      $this->getCache()->set($this->cacheKey, $count);
-+      $this->cache->set($this->cacheKey, $count);
-     }
-     else {
-       // Caching is in play, first try to retrieve a cached count.
+@@ -501,7 +510,7 @@ public function count($refresh = FALSE) {
+     // Return the cached count if we are caching counts and a refresh is not
+     // requested.
+     if ($this->cacheCounts && !$refresh) {
 -      $cache_object = $this->getCache()->get($this->cacheKey, 'cache');
 +      $cache_object = $this->cache->get($this->cacheKey, 'cache');
        if (is_object($cache_object)) {
-         // Success.
-         $count = $cache_object->data;
-@@ -425,26 +434,13 @@ public function count($refresh = FALSE) {
-         // No cached count, ask the derived class to count 'em up, and cache
-         // the result.
-         $count = $this->doCount();
--        $this->getCache()->set($this->cacheKey, $count);
-+        $this->cache->set($this->cacheKey, $count);
+         return $cache_object->data;
        }
+@@ -509,25 +518,12 @@ public function count($refresh = FALSE) {
+     $count = $this->doCount();
+     // Update the cache if we are caching counts.
+     if ($this->cacheCounts) {
+-      $this->getCache()->set($this->cacheKey, $count);
++      $this->cache->set($this->cacheKey, $count);
      }
      return $count;
    }
@@ -224,30 +209,31 @@
     * iterator_count function.
     *
 diff --git a/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
-index ee43451..d737b1a 100644
+index 4a1c35e..4481be3 100644
 --- a/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
 +++ b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
-@@ -2,8 +2,9 @@
+@@ -2,9 +2,10 @@
  
  namespace Drupal\migrate\Plugin\migrate\source;
  
 +use Drupal\Core\Cache\CacheBackendInterface;
+ use Drupal\Core\Database\ConnectionNotDefinedException;
  use Drupal\Core\Database\Database;
 -use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
 +use Drupal\Core\Extension\ModuleHandlerInterface;
  use Drupal\Core\State\StateInterface;
+ use Drupal\migrate\Exception\RequirementsException;
  use Drupal\migrate\MigrateException;
- use Drupal\migrate\Plugin\MigrationInterface;
-@@ -20,7 +21,7 @@
-  * is present, it is used as a database connection information array to define
-  * the connection.
+@@ -65,7 +66,7 @@
+  * @see https://www.drupal.org/docs/8/api/database-api
+  * @see \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase
   */
--abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPluginInterface {
+-abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPluginInterface, RequirementsInterface {
 +abstract class SqlBase extends SourcePluginBase {
  
    /**
     * The query string.
-@@ -62,8 +63,8 @@
+@@ -107,8 +108,8 @@
    /**
     * {@inheritdoc}
     */
@@ -258,7 +244,7 @@
      $this->state = $state;
    }
  
-@@ -76,6 +77,8 @@ public static function create(ContainerInterface $container, array $configuratio
+@@ -121,6 +122,8 @@ public static function create(ContainerInterface $container, array $configuratio
        $plugin_id,
        $plugin_definition,
        $migration,
@@ -267,11 +253,29 @@
        $container->get('state')
      );
    }
+diff --git a/core/modules/migrate/tests/src/Kernel/MigrateSqlSourceTestBase.php b/core/modules/migrate/tests/src/Kernel/MigrateSqlSourceTestBase.php
+index fcae35c..4174c38 100644
+--- a/core/modules/migrate/tests/src/Kernel/MigrateSqlSourceTestBase.php
++++ b/core/modules/migrate/tests/src/Kernel/MigrateSqlSourceTestBase.php
+@@ -2,9 +2,13 @@
+ 
+ namespace Drupal\Tests\migrate\Kernel;
+ 
++use Drupal\Core\Cache\CacheBackendInterface;
+ use Drupal\Core\Cache\MemoryCounterBackendFactory;
+ use Drupal\sqlite\Driver\Database\sqlite\Connection;
+ use Drupal\Core\DependencyInjection\ContainerBuilder;
++use Drupal\Core\Entity\EntityTypeManagerInterface;
++use Drupal\Core\Extension\ModuleHandlerInterface;
++use Drupal\Core\State\StateInterface;
+ 
+ /**
+  * Base class for tests of Migrate source plugins that use a database.
 diff --git a/core/modules/migrate/tests/src/Unit/MigrateSourceTest.php b/core/modules/migrate/tests/src/Unit/MigrateSourceTest.php
-index 4a462e9..3e3d906 100644
+index 8f5d2e6..70c0a6a 100644
 --- a/core/modules/migrate/tests/src/Unit/MigrateSourceTest.php
 +++ b/core/modules/migrate/tests/src/Unit/MigrateSourceTest.php
-@@ -105,8 +105,15 @@ protected function getSource($configuration = [], $migrate_config = [], $status
+@@ -109,8 +109,15 @@ protected function getSource($configuration = [], $migrate_config = [], $status
        ->method('getRowBySource')
        ->willReturn($id_map_array);
  
@@ -286,14 +290,14 @@
 +      $this->getMock(CacheBackendInterface::class),
 +    ];
 +    $methods = ['fields', 'getIds', '__toString', 'prepareRow', 'initializeIterator'];
-     $source_plugin = $this->getMock(SourcePluginBase::class, $methods, $constructor_args);
- 
-     $source_plugin
-@@ -135,11 +142,6 @@ protected function getSource($configuration = [], $migrate_config = [], $status
+     $source_plugin = $this->getMockBuilder(SourcePluginBase::class)
+       ->onlyMethods($methods)
+       ->setConstructorArgs($constructor_args)
+@@ -142,11 +149,6 @@ protected function getSource($configuration = [], $migrate_config = [], $status
        ->method('initializeIterator')
        ->willReturn($iterator);
  
--    $module_handler = $this->getMock(ModuleHandlerInterface::class);
+-    $module_handler = $this->createMock(ModuleHandlerInterface::class);
 -    $source_plugin
 -      ->method('getModuleHandler')
 -      ->willReturn($module_handler);
@@ -301,7 +305,7 @@
      $this->migration
        ->method('getSourcePlugin')
        ->willReturn($source_plugin);
-@@ -184,13 +186,14 @@ public function testCount() {
+@@ -191,13 +193,14 @@ public function testCount() {
  
      $this->migrationConfiguration['id'] = 'test_migration';
      $migration = $this->getMigration();
@@ -310,7 +314,7 @@
 +    $source = new StubSourceGeneratorPlugin([], '', [], $migration, $module_handler, $cache);
  
      // Test the skipCount property's default value.
-     $this->assertEquals(-1, $source->count());
+     $this->assertEquals(MigrateSourceInterface::NOT_COUNTABLE, $source->count());
  
      // Test the count value using a generator.
 -    $source = new StubSourceGeneratorPlugin(['skip_count' => FALSE], '', [], $migration);
@@ -318,12 +322,13 @@
      $this->assertEquals(3, $source->count());
    }
  
-@@ -283,19 +286,19 @@ public function testNewHighwater() {
+@@ -289,20 +292,20 @@ public function testNewHighwater() {
+    */
    public function testPrepareRow() {
      $this->migrationConfiguration['id'] = 'test_migration';
- 
++  
 +    $module_handler = $this->prophesize(ModuleHandlerInterface::class);
-+
+ 
      // Get a new migration with an id.
      $migration = $this->getMigration();
 -    $source = new StubSourcePlugin([], '', [], $migration);
@@ -341,7 +346,7 @@
  
      // Ensure we don't log this to the mapping table.
      $this->idMap->expects($this->never())
-@@ -304,7 +307,7 @@ public function testPrepareRow() {
+@@ -311,7 +314,7 @@ public function testPrepareRow() {
      $this->assertTrue($source->prepareRow($row));
  
      // Track_changes...
@@ -350,7 +355,7 @@
      $row2 = $this->prophesize(Row::class);
      $row2->rehash()
        ->shouldBeCalled();
-@@ -314,7 +317,6 @@ public function testPrepareRow() {
+@@ -321,7 +324,6 @@ public function testPrepareRow() {
      $module_handler->invokeAll('migrate_' . $migration->id() . '_prepare_row', [$row2, $source, $migration])
        ->willReturn([TRUE, TRUE])
        ->shouldBeCalled();
@@ -358,7 +363,7 @@
      $this->assertTrue($source->prepareRow($row2->reveal()));
    }
  
-@@ -326,11 +328,12 @@ public function testPrepareRow() {
+@@ -333,11 +335,12 @@ public function testPrepareRow() {
    public function testPrepareRowGlobalPrepareSkip() {
      $this->migrationConfiguration['id'] = 'test_migration';
  
@@ -373,7 +378,7 @@
      // Return a failure from a prepare row hook.
      $module_handler->invokeAll('migrate_prepare_row', [$row, $source, $migration])
        ->willReturn([TRUE, FALSE, TRUE])
-@@ -338,7 +341,6 @@ public function testPrepareRowGlobalPrepareSkip() {
+@@ -345,7 +348,6 @@ public function testPrepareRowGlobalPrepareSkip() {
      $module_handler->invokeAll('migrate_' . $migration->id() . '_prepare_row', [$row, $source, $migration])
        ->willReturn([TRUE, TRUE])
        ->shouldBeCalled();
@@ -381,12 +386,12 @@
  
      $this->idMap->expects($this->once())
        ->method('saveIdMapping')
-@@ -355,11 +357,12 @@ public function testPrepareRowGlobalPrepareSkip() {
+@@ -362,11 +364,12 @@ public function testPrepareRowGlobalPrepareSkip() {
    public function testPrepareRowMigratePrepareSkip() {
      $this->migrationConfiguration['id'] = 'test_migration';
  
 +    $module_handler = $this->prophesize(ModuleHandlerInterface::class);
-+
++    
      $migration = $this->getMigration();
 -    $source = new StubSourcePlugin([], '', [], $migration);
 +    $source = new StubSourcePlugin([], '', [], $migration, $module_handler->reveal(), $this->getMock(CacheBackendInterface::class));
@@ -396,7 +401,7 @@
      // Return a failure from a prepare row hook.
      $module_handler->invokeAll('migrate_prepare_row', [$row, $source, $migration])
        ->willReturn([TRUE, TRUE])
-@@ -367,7 +370,6 @@ public function testPrepareRowMigratePrepareSkip() {
+@@ -374,7 +377,6 @@ public function testPrepareRowMigratePrepareSkip() {
      $module_handler->invokeAll('migrate_' . $migration->id() . '_prepare_row', [$row, $source, $migration])
        ->willReturn([TRUE, FALSE, TRUE])
        ->shouldBeCalled();
@@ -404,12 +409,13 @@
  
      $this->idMap->expects($this->once())
        ->method('saveIdMapping')
-@@ -384,11 +386,12 @@ public function testPrepareRowMigratePrepareSkip() {
+@@ -391,11 +393,13 @@ public function testPrepareRowMigratePrepareSkip() {
    public function testPrepareRowPrepareException() {
      $this->migrationConfiguration['id'] = 'test_migration';
  
 +    $module_handler = $this->prophesize(ModuleHandlerInterface::class);
 +
++
      $migration = $this->getMigration();
 -    $source = new StubSourcePlugin([], '', [], $migration);
 +    $source = new StubSourcePlugin([], '', [], $migration, $module_handler->reveal(), $this->getMock(CacheBackendInterface::class));
@@ -419,7 +425,7 @@
      // Return a failure from a prepare row hook.
      $module_handler->invokeAll('migrate_prepare_row', [$row, $source, $migration])
        ->willReturn([TRUE, TRUE])
-@@ -396,7 +399,6 @@ public function testPrepareRowPrepareException() {
+@@ -403,7 +407,6 @@ public function testPrepareRowPrepareException() {
      $module_handler->invokeAll('migrate_' . $migration->id() . '_prepare_row', [$row, $source, $migration])
        ->willThrow(new MigrateSkipRowException())
        ->shouldBeCalled();
@@ -427,7 +433,7 @@
  
      // This will only be called on the first prepare because the second
      // explicitly avoids it.
-@@ -420,7 +422,9 @@ public function testPrepareRowPrepareException() {
+@@ -427,7 +430,9 @@ public function testPrepareRowPrepareException() {
    public function testDefaultPropertiesValues() {
      $this->migrationConfiguration['id'] = 'test_migration';
      $migration = $this->getMigration();
@@ -438,7 +444,7 @@
  
      // Test the default value of the skipCount Value;
      $this->assertTrue($source->getSkipCount());
-@@ -453,16 +457,6 @@ protected function getMigrateExecutable($migration) {
+@@ -460,16 +465,6 @@ protected function getMigrateExecutable($migration) {
  class StubSourcePlugin extends SourcePluginBase {
  
    /**
@@ -455,132 +461,55 @@
     * {@inheritdoc}
     */
    public function fields() {
-diff --git a/core/modules/migrate/tests/src/Unit/MigrateSqlSourceTestCase.php b/core/modules/migrate/tests/src/Unit/MigrateSqlSourceTestCase.php
-index 962a75d..b7bf7d4 100644
---- a/core/modules/migrate/tests/src/Unit/MigrateSqlSourceTestCase.php
-+++ b/core/modules/migrate/tests/src/Unit/MigrateSqlSourceTestCase.php
-@@ -2,11 +2,15 @@
- 
- namespace Drupal\Tests\migrate\Unit;
- 
-+use Drupal\Core\Cache\CacheBackendInterface;
- use Drupal\Core\Database\Query\SelectInterface;
- use Drupal\Core\DependencyInjection\ContainerBuilder;
- use Drupal\Core\DependencyInjection\ContainerNotInitializedException;
- use Drupal\Core\KeyValueStore\KeyValueFactoryInterface;
- use Drupal\Core\KeyValueStore\KeyValueStoreInterface;
-+use Drupal\Core\Entity\EntityManagerInterface;
-+use Drupal\Core\Extension\ModuleHandlerInterface;
-+use Drupal\Core\State\StateInterface;
- 
- /**
-  * Base class for Migrate module source unit tests.
-@@ -80,10 +84,6 @@
-    * {@inheritdoc}
-    */
-   protected function setUp() {
--    $module_handler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
--    $state = $this->getMock('Drupal\Core\State\StateInterface');
--    $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
--
-     // Mock a key-value store to return high-water values.
-     $key_value = $this->getMock(KeyValueStoreInterface::class);
- 
-@@ -103,6 +103,14 @@ protected function setUp() {
-       $container = new ContainerBuilder();
-     }
-     $container->set('keyvalue', $key_value_factory);
-+    $container
-+      ->set('module_handler', $this->getMock(ModuleHandlerInterface::class));
-+    $container
-+      ->set('cache.migrate', $this->getMock(CacheBackendInterface::class));
-+    $container
-+      ->set('state', $this->getMock(StateInterface::class));
-+    $container
-+      ->set('entity.manager', $this->getMock(EntityManagerInterface::class));
-     \Drupal::setContainer($container);
- 
-     $migration = $this->getMigration();
-@@ -110,20 +118,20 @@ protected function setUp() {
-       ->method('getHighWater')
-       ->will($this->returnValue(static::ORIGINAL_HIGH_WATER));
- 
--    // Setup the plugin.
--    $plugin_class = static::PLUGIN_CLASS;
--    $plugin = new $plugin_class($this->migrationConfiguration['source'], $this->migrationConfiguration['source']['plugin'], array(), $migration, $state, $entity_manager);
-+    $plugin = call_user_func(
-+      [static::PLUGIN_CLASS, 'create'],
-+      $container,
-+      $this->migrationConfiguration['source'],
-+      $this->migrationConfiguration['source']['plugin'],
-+      [],
-+      $migration
-+    );
- 
--    // Do some reflection to set the database and moduleHandler.
-+    // Do some reflection to set the database.
-     $plugin_reflection = new \ReflectionClass($plugin);
-     $database_property = $plugin_reflection->getProperty('database');
-     $database_property->setAccessible(TRUE);
--    $module_handler_property = $plugin_reflection->getProperty('moduleHandler');
--    $module_handler_property->setAccessible(TRUE);
--
--    // Set the database and the module handler onto our plugin.
-     $database_property->setValue($plugin, $this->getDatabase($this->databaseContents + array('test_map' => array())));
--    $module_handler_property->setValue($plugin, $module_handler);
- 
-     $plugin->setStringTranslation($this->getStringTranslationStub());
-     $migration->expects($this->any())
 diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php
-index 3af971c..35f8759 100644
+index 0df37ea..131e90b 100644
 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php
 +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php
-@@ -3,9 +3,10 @@
+@@ -3,8 +3,10 @@
  namespace Drupal\migrate_drupal\Plugin\migrate\source;
  
  use Drupal\Component\Plugin\DependentPluginInterface;
 +use Drupal\Core\Cache\CacheBackendInterface;
  use Drupal\Core\Entity\DependencyTrait;
- use Drupal\Core\Entity\EntityManagerInterface;
--use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+ use Drupal\Core\Entity\EntityTypeManagerInterface;
 +use Drupal\Core\Extension\ModuleHandlerInterface;
  use Drupal\Core\State\StateInterface;
  use Drupal\migrate\Plugin\MigrationInterface;
  use Drupal\migrate\Exception\RequirementsException;
-@@ -19,7 +20,7 @@
-  * Mainly to let children retrieve information from the origin system in an
-  * easier way.
+@@ -27,7 +29,7 @@
+  * @see \Drupal\migrate\Plugin\migrate\source\SqlBase
+  * @see \Drupal\migrate\Plugin\migrate\source\SourcePluginBase
   */
--abstract class DrupalSqlBase extends SqlBase implements ContainerFactoryPluginInterface, RequirementsInterface, DependentPluginInterface {
-+abstract class DrupalSqlBase extends SqlBase implements RequirementsInterface, DependentPluginInterface {
+-abstract class DrupalSqlBase extends SqlBase implements DependentPluginInterface {
++abstract class DrupalSqlBase extends SqlBase implements DependentPluginInterface {abstract class DrupalSqlBase extends SqlBase implements RequirementsInterface, DependentPluginInterface {
  
    use DependencyTrait;
  
-@@ -47,8 +48,8 @@
+@@ -55,8 +57,8 @@
    /**
     * {@inheritdoc}
     */
--  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager) {
+-  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityTypeManagerInterface $entity_type_manager) {
 -    parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state);
 +  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache, StateInterface $state, EntityManagerInterface $entity_manager) {
 +    parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $module_handler, $cache, $state);
-     $this->entityManager = $entity_manager;
+     $this->entityTypeManager = $entity_type_manager;
    }
  
-@@ -85,6 +86,8 @@ public static function create(ContainerInterface $container, array $configuratio
+@@ -93,6 +95,8 @@ public static function create(ContainerInterface $container, array $configuratio
        $plugin_id,
        $plugin_definition,
        $migration,
 +      $container->get('module_handler'),
 +      $container->get('cache.migrate'),
        $container->get('state'),
-       $container->get('entity.manager')
+       $container->get('entity_type.manager')
      );
 diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/EmptySource.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/EmptySource.php
-index 6792e5e..32b5ad5 100644
+index 7c6e260..d578ecf 100644
 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/EmptySource.php
 +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/EmptySource.php
-@@ -3,13 +3,13 @@
+@@ -3,12 +3,13 @@
  namespace Drupal\migrate_drupal\Plugin\migrate\source;
  
  use Drupal\Component\Plugin\DependentPluginInterface;
@@ -590,14 +519,13 @@
  use Symfony\Component\DependencyInjection\ContainerInterface;
  use Drupal\migrate\Plugin\MigrationInterface;
  use Drupal\migrate\Plugin\migrate\source\EmptySource as BaseEmptySource;
- use Drupal\Core\Entity\EntityManagerInterface;
+ use Drupal\Core\Entity\EntityTypeManagerInterface;
 -use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
--
  
  /**
   * Source returning an empty row with Drupal specific config dependencies.
-@@ -18,7 +18,7 @@
-  *   id = "md_empty"
+@@ -24,7 +25,7 @@
+  *   source_module = "system",
   * )
   */
 -class EmptySource extends BaseEmptySource implements ContainerFactoryPluginInterface, DependentPluginInterface {
@@ -605,42 +533,42 @@
  
    use DependencyTrait;
  
-@@ -32,8 +32,8 @@ class EmptySource extends BaseEmptySource implements ContainerFactoryPluginInter
+@@ -38,8 +39,8 @@ class EmptySource extends BaseEmptySource implements ContainerFactoryPluginInter
    /**
     * {@inheritdoc}
     */
--  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityManagerInterface $entity_manager) {
+-  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityTypeManagerInterface $entity_type_manager) {
 -    parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
 +  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache, EntityManagerInterface $entity_manager) {
 +    parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $module_handler, $cache);
-     $this->entityManager = $entity_manager;
+     $this->entityTypeManager = $entity_type_manager;
    }
  
-@@ -46,6 +46,8 @@ public static function create(ContainerInterface $container, array $configuratio
+@@ -52,6 +53,8 @@ public static function create(ContainerInterface $container, array $configuratio
        $plugin_id,
        $plugin_definition,
        $migration,
 +      $container->get('module_handler'),
 +      $container->get('cache.migrate'),
-       $container->get('entity.manager')
+       $container->get('entity_type.manager')
      );
    }
 diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/Variable.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/Variable.php
-index 2d8c3cc..ab69d3e 100644
+index 0b83a09..34a4426 100644
 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/Variable.php
 +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/Variable.php
 @@ -2,10 +2,6 @@
  
  namespace Drupal\migrate_drupal\Plugin\migrate\source;
  
--use Drupal\Core\Entity\EntityManagerInterface;
+-use Drupal\Core\Entity\EntityTypeManagerInterface;
 -use Drupal\Core\State\StateInterface;
 -use Drupal\migrate\Plugin\MigrationInterface;
 -
  /**
-  * Drupal variable source from database.
+  * Drupal 6/7 variable source from database.
   *
-@@ -19,21 +15,6 @@
+@@ -83,30 +79,6 @@
  class Variable extends DrupalSqlBase {
  
    /**
@@ -651,18 +579,27 @@
 -  protected $variables;
 -
 -  /**
+-   * The variables that result in no row if any are missing from the source.
+-   *
+-   * @var array
+-   */
+-  protected $variablesNoRowIfMissing;
+-
+-  /**
 -   * {@inheritdoc}
 -   */
--  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager) {
--    parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager);
--    $this->variables = $this->configuration['variables'];
+-  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityTypeManagerInterface $entity_type_manager) {
+-    parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_type_manager);
+-    $this->variablesNoRowIfMissing = $this->configuration['variables_no_row_if_missing'] ?? [];
+-    $variables = $this->configuration['variables'] ?? [];
+-    $this->variables = array_unique(array_merge(array_values($variables), array_values($this->variablesNoRowIfMissing)));
 -  }
 -
 -  /**
     * {@inheritdoc}
     */
    protected function initializeIterator() {
-@@ -51,7 +32,7 @@ protected function initializeIterator() {
+@@ -128,7 +100,7 @@ protected function initializeIterator() {
    protected function values() {
      // Create an ID field so we can record migration in the map table.
      // Arbitrarily, use the first variable name.
@@ -671,7 +608,7 @@
      return $values + array_map('unserialize', $this->prepareQuery()->execute()->fetchAllKeyed());
    }
  
-@@ -66,7 +47,8 @@ public function count() {
+@@ -151,7 +123,8 @@ protected function doCount() {
     * {@inheritdoc}
     */
    public function fields() {
@@ -681,63 +618,17 @@
    }
  
    /**
-@@ -76,7 +58,7 @@ public function query() {
+@@ -161,7 +134,7 @@ public function query() {
      return $this->getDatabase()
        ->select('variable', 'v')
-       ->fields('v', array('name', 'value'))
+       ->fields('v', ['name', 'value'])
 -      ->condition('name', $this->variables, 'IN');
 +      ->condition('name', $this->configuration['variables'], 'IN');
    }
  
    /**
-diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/i18nVariable.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/i18nVariable.php
-index 93832aa..7447562 100644
---- a/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/i18nVariable.php
-+++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/i18nVariable.php
-@@ -2,9 +2,6 @@
- 
- namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
- 
--use Drupal\Core\Entity\EntityManagerInterface;
--use Drupal\Core\State\StateInterface;
--use Drupal\migrate\Plugin\MigrationInterface;
- use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
- 
- /**
-@@ -17,21 +14,6 @@
- class i18nVariable extends DrupalSqlBase {
- 
-   /**
--   * The variable names to fetch.
--   *
--   * @var array
--   */
--  protected $variables;
--
--  /**
--   * {@inheritdoc}
--   */
--  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager) {
--    parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager);
--    $this->variables = $this->configuration['variables'];
--  }
--
--  /**
-    * {@inheritdoc}
-    */
-   protected function initializeIterator() {
-@@ -76,7 +58,8 @@ public function count() {
-    * {@inheritdoc}
-    */
-   public function fields() {
--    return array_combine($this->variables, $this->variables);
-+    $variables = $this->configuration['variables'];
-+    return array_combine($variables, $variables);
-   }
- 
-   /**
 diff --git a/core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php b/core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php
-index f2254dc..23aab59 100644
+index 8792b10..4839249 100644
 --- a/core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php
 +++ b/core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php
 @@ -2,6 +2,8 @@
@@ -746,26 +637,29 @@
  
 +use Drupal\Core\Cache\CacheBackendInterface;
 +use Drupal\Core\Extension\ModuleHandlerInterface;
+ use Drupal\Core\Database\Connection;
  use Drupal\Tests\migrate\Unit\MigrateTestCase;
  use Drupal\migrate\Exception\RequirementsException;
- 
-@@ -44,11 +46,13 @@ class DrupalSqlBaseTest extends MigrateTestCase {
-   public function testSourceProviderNotActive() {
-     $plugin_definition['requirements_met'] = TRUE;
-     $plugin_definition['source_provider'] = 'module1';
+@@ -68,6 +70,8 @@ public function setUp(): void {
+     parent::setUp();
+     $this->pluginDefinition['requirements_met'] = TRUE;
+     $this->pluginDefinition['source_module'] = 'module1';
 +    $module_handler = $this->getMock(ModuleHandlerInterface::class);
 +    $cache = $this->getMock(CacheBackendInterface::class);
-     /** @var \Drupal\Core\State\StateInterface $state */
-     $state = $this->getMock('Drupal\Core\State\StateInterface');
-     /** @var \Drupal\Core\Entity\EntityManagerInterface $entity_manager */
-     $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
--    $plugin = new TestDrupalSqlBase([], 'placeholder_id', $plugin_definition, $this->getMigration(), $state, $entity_manager);
+     $this->state = $this->createMock('Drupal\Core\State\StateInterface');
+     $this->entityTypeManager = $this->createMock('Drupal\Core\Entity\EntityTypeManagerInterface');
+   }
+@@ -76,7 +80,7 @@ public function setUp(): void {
+    * @covers ::checkRequirements
+    */
+   public function testSourceProviderNotActive() {
+-    $plugin = new TestDrupalSqlBase([], 'placeholder_id', $this->pluginDefinition, $this->getMigration(), $this->state, $this->entityTypeManager);
 +    $plugin = new TestDrupalSqlBase([], 'placeholder_id', $plugin_definition, $this->getMigration(), $module_handler, $cache, $state, $entity_manager);
      $plugin->setDatabase($this->getDatabase($this->databaseContents));
-     $system_data = $plugin->getSystemData();
-     $this->setExpectedException(RequirementsException::class, 'The module module1 is not enabled in the source site.');
+     $this->expectException(RequirementsException::class);
+     $this->expectExceptionMessage('The module module1 is not enabled in the source site.');
 diff --git a/core/modules/migrate_drupal/tests/src/Unit/source/d6/Drupal6SqlBaseTest.php b/core/modules/migrate_drupal/tests/src/Unit/source/d6/Drupal6SqlBaseTest.php
-index 845ce78..e5fdd0e 100644
+index 87731aa..ea7a0ab 100644
 --- a/core/modules/migrate_drupal/tests/src/Unit/source/d6/Drupal6SqlBaseTest.php
 +++ b/core/modules/migrate_drupal/tests/src/Unit/source/d6/Drupal6SqlBaseTest.php
 @@ -7,6 +7,8 @@
@@ -776,43 +670,43 @@
 +use Drupal\Core\Extension\ModuleHandlerInterface;
  use Drupal\Tests\migrate\Unit\MigrateTestCase;
  
- /**
-@@ -68,11 +70,13 @@ class Drupal6SqlBaseTest extends MigrateTestCase {
+ // cspell:ignore throttleable
+@@ -70,11 +72,13 @@ class Drupal6SqlBaseTest extends MigrateTestCase {
     */
-   protected function setUp() {
+   protected function setUp(): void {
      $plugin = 'placeholder_id';
 +    $module_handler = $this->getMock(ModuleHandlerInterface::class);
 +    $cache = $this->getMock(CacheBackendInterface::class);
      /** @var \Drupal\Core\State\StateInterface $state */
-     $state = $this->getMock('Drupal\Core\State\StateInterface');
-     /** @var \Drupal\Core\Entity\EntityManagerInterface $entity_manager */
-     $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
--    $this->base = new TestDrupal6SqlBase($this->migrationConfiguration, $plugin, array(), $this->getMigration(), $state, $entity_manager);
+     $state = $this->createMock('Drupal\Core\State\StateInterface');
+     /** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
+     $entity_type_manager = $this->createMock('Drupal\Core\Entity\EntityTypeManagerInterface');
+-    $this->base = new TestDrupal6SqlBase($this->migrationConfiguration, $plugin, [], $this->getMigration(), $state, $entity_type_manager);
 +    $this->base = new TestDrupal6SqlBase($this->migrationConfiguration, $plugin, array(), $this->getMigration(), $module_handler, $cache, $state, $entity_manager);
      $this->base->setDatabase($this->getDatabase($this->databaseContents));
    }
  
-@@ -180,18 +184,6 @@ public function setDatabase(Connection $database) {
+@@ -170,18 +174,6 @@ public function query() {
    }
  
    /**
--   * Tweaks Drupal6SqlBase to set a new module handler for tests.
+-   * Tweaks Drupal6SqlBase to set a new database connection for tests.
 -   *
--   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
--   *   The new module handler to use.
+-   * @param \Drupal\Core\Database\Connection $database
+-   *   The new connection to use.
 -   *
 -   * @see \Drupal\Tests\migrate\Unit\MigrateSqlTestCase
 -   */
--  public function setModuleHandler(ModuleHandlerInterface $module_handler) {
--    $this->moduleHandler = $module_handler;
+-  public function setDatabase(Connection $database) {
+-    $this->database = $database;
 -  }
 -
 -  /**
-    * Wrapper method to test protected method moduleExists().
-    */
-   public function moduleExistsWrapper($module) {
+    * Tweaks Drupal6SqlBase to set a new module handler for tests.
+    *
+    * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
 diff --git a/core/modules/node/src/Plugin/migrate/source/d6/Node.php b/core/modules/node/src/Plugin/migrate/source/d6/Node.php
-index 2e4d1a6..8ef24f6 100644
+index a1a3166..d1552ca 100644
 --- a/core/modules/node/src/Plugin/migrate/source/d6/Node.php
 +++ b/core/modules/node/src/Plugin/migrate/source/d6/Node.php
 @@ -2,6 +2,7 @@
@@ -821,23 +715,23 @@
  
 +use Drupal\Core\Cache\CacheBackendInterface;
  use Drupal\Core\Database\Query\SelectInterface;
- use Drupal\Core\Entity\EntityManagerInterface;
+ use Drupal\Core\Entity\EntityTypeManagerInterface;
  use Drupal\Core\Extension\ModuleHandler;
-@@ -49,8 +50,8 @@ class Node extends DrupalSqlBase {
+@@ -78,8 +79,8 @@ class Node extends DrupalSqlBase {
    /**
     * {@inheritdoc}
     */
--  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager, ModuleHandler $module_handler) {
--    parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager);
+-  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityTypeManagerInterface $entity_type_manager, ModuleHandler $module_handler) {
+-    parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_type_manager);
 +  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager, ModuleHandler $module_handler, CacheBackendInterface $cache) {
 +    parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $module_handler, $cache, $state, $entity_manager);
      $this->moduleHandler = $module_handler;
    }
  
-@@ -65,7 +66,8 @@ public static function create(ContainerInterface $container, array $configuratio
+@@ -94,7 +95,8 @@ public static function create(ContainerInterface $container, array $configuratio
        $migration,
        $container->get('state'),
-       $container->get('entity.manager'),
+       $container->get('entity_type.manager'),
 -      $container->get('module_handler')
 +      $container->get('module_handler'),
 +      $container->get('cache.migrate')
