From 3c615f732aebdd2a5210428ef1acac4302861e1b Mon Sep 17 00:00:00 2001
From: Ivan Doroshenko <Matroskeen@3426249.no-reply.drupal.org>
Date: Fri, 8 Apr 2022 10:15:15 +0000
Subject: [PATCH] Issue #3273003 by Matroskeen: Fix deprecation warnings.

---
 .../migrate_example_setup.install               | 14 +++++++-------
 .../tests/src/Kernel/MigrateExampleTest.php     |  4 +---
 .../migrate_json_example.install                |  4 +++-
 src/DataParserPluginBase.php                    | 17 +++++++++++------
 .../migrate_plus/data_parser/XmlTrait.php       |  2 +-
 5 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/migrate_example/migrate_example_setup/migrate_example_setup.install b/migrate_example/migrate_example_setup/migrate_example_setup.install
index 89ea5287..a8e8c8ae 100644
--- a/migrate_example/migrate_example_setup/migrate_example_setup.install
+++ b/migrate_example/migrate_example_setup/migrate_example_setup.install
@@ -325,7 +325,7 @@ function migrate_example_beer_data_node(): void {
       'Blab Blah Blah Green',
       'Green',
       'Netherlands|Belgium',
-      0,
+      1,
       'heineken.jpg',
       'Heinekin alt',
       'Heinekin title',
@@ -337,7 +337,7 @@ function migrate_example_beer_data_node(): void {
       'We love Miller Brewing',
       'Tasteless',
       'USA|Canada',
-      1,
+      2,
       NULL,
       NULL,
       NULL,
@@ -349,7 +349,7 @@ function migrate_example_beer_data_node(): void {
       'English occasionally get something right',
       'A treat',
       'United Kingdom',
-      1,
+      2,
       NULL,
       NULL,
       NULL,
@@ -439,10 +439,10 @@ function migrate_example_beer_data_comment(): void {
   $query = \Drupal::database()->insert('migrate_example_beer_comment')
     ->fields($fields);
   $data = [
-    [99999998, NULL, 'im first', 'full body', 'alice', 'alice@example.com', 0],
-    [99999998, NULL, 'im second', 'aromatic', 'alice', 'alice@example.com', 0],
-    [99999999, NULL, 'im parent', 'malty', 'alice', 'alice@example.com', 0],
-    [99999999, 1, 'im child', 'cold body', 'bob', NULL, 1],
+    [99999998, NULL, 'im first', 'full body', 'alice', 'alice@example.com', 1],
+    [99999998, NULL, 'im second', 'aromatic', 'alice', 'alice@example.com', 1],
+    [99999999, NULL, 'im parent', 'malty', 'alice', 'alice@example.com', 1],
+    [99999999, 1, 'im child', 'cold body', 'bob', NULL, 2],
     [
       99999999,
       4,
diff --git a/migrate_example/tests/src/Kernel/MigrateExampleTest.php b/migrate_example/tests/src/Kernel/MigrateExampleTest.php
index c9b6a143..6933265b 100755
--- a/migrate_example/tests/src/Kernel/MigrateExampleTest.php
+++ b/migrate_example/tests/src/Kernel/MigrateExampleTest.php
@@ -59,9 +59,7 @@ final class MigrateExampleTest extends MigrateDrupalTestBase {
    */
   public function testBeerMigration(): void {
     $users = \Drupal::entityTypeManager()->getStorage('user')->loadMultiple();
-    // There are 4 users created in beer_user migration and 1 stub entity
-    // created during beer_node migration.
-    $this->assertCount(5, $users);
+    $this->assertCount(4, $users);
 
     $terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadMultiple();
     $this->assertCount(3, $terms);
diff --git a/migrate_json_example/migrate_json_example.install b/migrate_json_example/migrate_json_example.install
index b881aaa6..0eb4815e 100644
--- a/migrate_json_example/migrate_json_example.install
+++ b/migrate_json_example/migrate_json_example.install
@@ -18,7 +18,9 @@ function migrate_json_example_install(): void {
   \Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
 
   // Copy the example file to example directory.
-  $module_path = \Drupal::service('extension.list.module')->getPath('migrate_json_example');
+  // @todo Use \Drupal\Core\Extension\ExtensionPathResolver::getPath() when we
+  // require Drupal > 9.3.0.
+  $module_path = \Drupal::moduleHandler()->getModule('migrate_json_example')->getPath();
   $file_source = $module_path . '/artifacts/products.json';
   \Drupal::service('file_system')->copy($file_source, $directory . '/products.json', FileSystemInterface::EXISTS_REPLACE);
 }
diff --git a/src/DataParserPluginBase.php b/src/DataParserPluginBase.php
index c94e20d3..a86d11b0 100644
--- a/src/DataParserPluginBase.php
+++ b/src/DataParserPluginBase.php
@@ -59,7 +59,7 @@ abstract class DataParserPluginBase extends PluginBase implements DataParserPlug
   public function __construct(array $configuration, $plugin_id, $plugin_definition) {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->urls = $configuration['urls'];
-    $this->itemSelector = $configuration['item_selector'];
+    $this->itemSelector = $configuration['item_selector'] ?? '';
   }
 
   /**
@@ -82,7 +82,8 @@ abstract class DataParserPluginBase extends PluginBase implements DataParserPlug
   /**
    * {@inheritdoc}
    */
-  public function rewind(): void {
+  #[\ReturnTypeWillChange]
+  public function rewind() {
     $this->activeUrl = NULL;
     $this->next();
   }
@@ -90,7 +91,8 @@ abstract class DataParserPluginBase extends PluginBase implements DataParserPlug
   /**
    * {@inheritdoc}
    */
-  public function next(): void {
+  #[\ReturnTypeWillChange]
+  public function next() {
     $this->currentItem = $this->currentId = NULL;
     if (is_null($this->activeUrl)) {
       if (!$this->nextSource()) {
@@ -179,21 +181,24 @@ abstract class DataParserPluginBase extends PluginBase implements DataParserPlug
   /**
    * {@inheritdoc}
    */
-  public function key(): ?array {
+  #[\ReturnTypeWillChange]
+  public function key() {
     return $this->currentId;
   }
 
   /**
    * {@inheritdoc}
    */
-  public function valid(): bool {
+  #[\ReturnTypeWillChange]
+  public function valid() {
     return !empty($this->currentItem);
   }
 
   /**
    * {@inheritdoc}
    */
-  public function count(): int {
+  #[\ReturnTypeWillChange]
+  public function count() {
     return iterator_count($this);
   }
 
diff --git a/src/Plugin/migrate_plus/data_parser/XmlTrait.php b/src/Plugin/migrate_plus/data_parser/XmlTrait.php
index b298a688..ff92ef6e 100644
--- a/src/Plugin/migrate_plus/data_parser/XmlTrait.php
+++ b/src/Plugin/migrate_plus/data_parser/XmlTrait.php
@@ -58,7 +58,7 @@ trait XmlTrait {
         '@libxmlerrormessage' => trim((string) $error->message),
         '@libxmlerrorline' => $error->line,
         '@libxmlerrorcolumn' => $error->column,
-        '@libxmlerrorfile' => $error->file ?: NULL,
+        '@libxmlerrorfile' => $error->file,
       ]
     );
   }
-- 
GitLab