From 4af9bb6b4f3b62d69ac426de1dbb3b9d6546447e Mon Sep 17 00:00:00 2001
From: Michael Lee <lee.5151@osu.edu>
Date: Tue, 24 May 2022 12:09:24 -0400
Subject: [PATCH] Upgrading drupal/config_filter (1.8.0 => 1.9.0)

---
 composer.json                                 |  1 +
 composer.lock                                 | 16 ++++----
 vendor/composer/installed.json                | 16 ++++----
 vendor/composer/installed.php                 | 10 ++---
 .../config_filter/config_filter.info.yml      |  6 +--
 .../config_filter_split_test.info.yml         |  6 +--
 .../config_filter_test.info.yml               |  6 +--
 .../Kernel/ConfigFilterStorageFactoryTest.php |  4 +-
 .../src/Kernel/ConfigStorageTestTrait.php     | 40 ++++++++++++++++++-
 9 files changed, 73 insertions(+), 32 deletions(-)

diff --git a/composer.json b/composer.json
index 7b9f890c76..fff72e8c9d 100644
--- a/composer.json
+++ b/composer.json
@@ -100,6 +100,7 @@
         "drupal/cache_control_override": "^1.0@alpha",
         "drupal/ckeditor_indentblock": "1.0.0-beta2",
         "drupal/config_direct_save": "2.1",
+        "drupal/config_filter": "1.9",
         "drupal/config_ignore": "2.3",
         "drupal/config_update": "1.7",
         "drupal/console": "1.9.7",
diff --git a/composer.lock b/composer.lock
index de80c3e923..3b302bce30 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "ddbb6bfcc5492e80908375b84ecb45bb",
+    "content-hash": "accbf7ddece37756fc0fca6526e9861c",
     "packages": [
         {
             "name": "alchemy/zippy",
@@ -2446,17 +2446,17 @@
         },
         {
             "name": "drupal/config_filter",
-            "version": "1.8.0",
+            "version": "1.9.0",
             "source": {
                 "type": "git",
                 "url": "https://git.drupalcode.org/project/config_filter.git",
-                "reference": "8.x-1.8"
+                "reference": "8.x-1.9"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://ftp.drupal.org/files/projects/config_filter-8.x-1.8.zip",
-                "reference": "8.x-1.8",
-                "shasum": "5def5f97e79d6f5af6bb7007f012443475c90bfe"
+                "url": "https://ftp.drupal.org/files/projects/config_filter-8.x-1.9.zip",
+                "reference": "8.x-1.9",
+                "shasum": "cf6919fc5039771f8e6c2ed203f29ab0eca8d91f"
             },
             "require": {
                 "drupal/core": "^8 || ^9"
@@ -2467,8 +2467,8 @@
             "type": "drupal-module",
             "extra": {
                 "drupal": {
-                    "version": "8.x-1.8",
-                    "datestamp": "1603870062",
+                    "version": "8.x-1.9",
+                    "datestamp": "1649336052",
                     "security-coverage": {
                         "status": "covered",
                         "message": "Covered by Drupal's security advisory policy"
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
index 86c3899c9d..63de63df66 100644
--- a/vendor/composer/installed.json
+++ b/vendor/composer/installed.json
@@ -2522,18 +2522,18 @@
         },
         {
             "name": "drupal/config_filter",
-            "version": "1.8.0",
-            "version_normalized": "1.8.0.0",
+            "version": "1.9.0",
+            "version_normalized": "1.9.0.0",
             "source": {
                 "type": "git",
                 "url": "https://git.drupalcode.org/project/config_filter.git",
-                "reference": "8.x-1.8"
+                "reference": "8.x-1.9"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://ftp.drupal.org/files/projects/config_filter-8.x-1.8.zip",
-                "reference": "8.x-1.8",
-                "shasum": "5def5f97e79d6f5af6bb7007f012443475c90bfe"
+                "url": "https://ftp.drupal.org/files/projects/config_filter-8.x-1.9.zip",
+                "reference": "8.x-1.9",
+                "shasum": "cf6919fc5039771f8e6c2ed203f29ab0eca8d91f"
             },
             "require": {
                 "drupal/core": "^8 || ^9"
@@ -2544,8 +2544,8 @@
             "type": "drupal-module",
             "extra": {
                 "drupal": {
-                    "version": "8.x-1.8",
-                    "datestamp": "1603870062",
+                    "version": "8.x-1.9",
+                    "datestamp": "1649336052",
                     "security-coverage": {
                         "status": "covered",
                         "message": "Covered by Drupal's security advisory policy"
diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php
index 39a00312f7..264ae22187 100644
--- a/vendor/composer/installed.php
+++ b/vendor/composer/installed.php
@@ -5,7 +5,7 @@
         'type' => 'project',
         'install_path' => __DIR__ . '/../../',
         'aliases' => array(),
-        'reference' => 'e84dd64613669ee59f663ea0db62b53e321ee2c8',
+        'reference' => '62f37ad72d72a4a2361f19ce3d56789dd9095950',
         'name' => 'osu-asc-webservices/d8-upstream',
         'dev' => true,
     ),
@@ -503,12 +503,12 @@
             'dev_requirement' => false,
         ),
         'drupal/config_filter' => array(
-            'pretty_version' => '1.8.0',
-            'version' => '1.8.0.0',
+            'pretty_version' => '1.9.0',
+            'version' => '1.9.0.0',
             'type' => 'drupal-module',
             'install_path' => __DIR__ . '/../../web/modules/config_filter',
             'aliases' => array(),
-            'reference' => '8.x-1.8',
+            'reference' => '8.x-1.9',
             'dev_requirement' => false,
         ),
         'drupal/config_ignore' => array(
@@ -2101,7 +2101,7 @@
             'type' => 'project',
             'install_path' => __DIR__ . '/../../',
             'aliases' => array(),
-            'reference' => 'e84dd64613669ee59f663ea0db62b53e321ee2c8',
+            'reference' => '62f37ad72d72a4a2361f19ce3d56789dd9095950',
             'dev_requirement' => false,
         ),
         'pantheon-systems/quicksilver-pushback' => array(
diff --git a/web/modules/config_filter/config_filter.info.yml b/web/modules/config_filter/config_filter.info.yml
index 1cef5653b6..9d50c85330 100644
--- a/web/modules/config_filter/config_filter.info.yml
+++ b/web/modules/config_filter/config_filter.info.yml
@@ -5,7 +5,7 @@ core: 8.x
 core_version_requirement: ^8 || ^9
 package: Config
 
-# Information added by Drupal.org packaging script on 2020-10-28
-version: '8.x-1.8'
+# Information added by Drupal.org packaging script on 2022-04-07
+version: '8.x-1.9'
 project: 'config_filter'
-datestamp: 1603870063
+datestamp: 1649336058
diff --git a/web/modules/config_filter/tests/modules/config_filter_split_test/config_filter_split_test.info.yml b/web/modules/config_filter/tests/modules/config_filter_split_test/config_filter_split_test.info.yml
index 231453b850..32c02faf24 100644
--- a/web/modules/config_filter/tests/modules/config_filter_split_test/config_filter_split_test.info.yml
+++ b/web/modules/config_filter/tests/modules/config_filter_split_test/config_filter_split_test.info.yml
@@ -6,7 +6,7 @@ package: Testing
 dependencies:
   - config_filter:config_filter
 
-# Information added by Drupal.org packaging script on 2020-10-28
-version: '8.x-1.8'
+# Information added by Drupal.org packaging script on 2022-04-07
+version: '8.x-1.9'
 project: 'config_filter'
-datestamp: 1603870063
+datestamp: 1649336058
diff --git a/web/modules/config_filter/tests/modules/config_filter_test/config_filter_test.info.yml b/web/modules/config_filter/tests/modules/config_filter_test/config_filter_test.info.yml
index 7fec84b0ed..3d4835ec39 100644
--- a/web/modules/config_filter/tests/modules/config_filter_test/config_filter_test.info.yml
+++ b/web/modules/config_filter/tests/modules/config_filter_test/config_filter_test.info.yml
@@ -6,7 +6,7 @@ package: Testing
 dependencies:
   - config_filter:config_filter
 
-# Information added by Drupal.org packaging script on 2020-10-28
-version: '8.x-1.8'
+# Information added by Drupal.org packaging script on 2022-04-07
+version: '8.x-1.9'
 project: 'config_filter'
-datestamp: 1603870063
+datestamp: 1649336058
diff --git a/web/modules/config_filter/tests/src/Kernel/ConfigFilterStorageFactoryTest.php b/web/modules/config_filter/tests/src/Kernel/ConfigFilterStorageFactoryTest.php
index 3056cff58f..2e089d7453 100644
--- a/web/modules/config_filter/tests/src/Kernel/ConfigFilterStorageFactoryTest.php
+++ b/web/modules/config_filter/tests/src/Kernel/ConfigFilterStorageFactoryTest.php
@@ -13,6 +13,8 @@
  */
 class ConfigFilterStorageFactoryTest extends KernelTestBase {
 
+  use ConfigStorageTestTrait;
+
   /**
    * {@inheritdoc}
    */
@@ -38,7 +40,7 @@ public function testServiceProvider() {
     // Config Filter makes the sync storage a filtered storage.
     $this->assertInstanceOf(FilteredStorageInterface::class, $this->container->get('config.storage.sync'));
     // Export the configuration. The pirate filter changes system.site.
-    $this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
+    $this->copyConfig($this->getExportStorage(), $this->getSyncFileStorage());
 
     // The pirate filter changes the system.site when importing.
     $this->assertEquals(['system.site'], $this->configImporter()->getStorageComparer()->getChangelist('update'));
diff --git a/web/modules/config_filter/tests/src/Kernel/ConfigStorageTestTrait.php b/web/modules/config_filter/tests/src/Kernel/ConfigStorageTestTrait.php
index 3a6fee528e..0d8e293095 100644
--- a/web/modules/config_filter/tests/src/Kernel/ConfigStorageTestTrait.php
+++ b/web/modules/config_filter/tests/src/Kernel/ConfigStorageTestTrait.php
@@ -113,7 +113,7 @@ protected function getExportStorage(): StorageInterface {
     // Create a filtered storage.
     $filtered = $this->container->get('config_filter.storage_factory')->getFilteredStorage($memory, ['config.storage.sync']);
     // Then write the core export storage to this new storage.
-    $this->copyConfig($unfiltered, $filtered);
+    self::replaceAllStorageContents($unfiltered, $filtered);
 
     return $memory;
   }
@@ -155,4 +155,42 @@ protected static function assertStorageEquals(StorageInterface $expected, Storag
     }
   }
 
+  /**
+   * Copy the configuration from one storage to another and remove stale items.
+   *
+   * This method is the copy of how it worked prior to Drupal 9.4.
+   * See https://www.drupal.org/node/3273823 for more details.
+   *
+   * @param \Drupal\Core\Config\StorageInterface $source
+   *   The configuration storage to copy from.
+   * @param \Drupal\Core\Config\StorageInterface $target
+   *   The configuration storage to copy to.
+   */
+  private static function replaceAllStorageContents(StorageInterface $source, StorageInterface &$target) {
+    // Make sure there is no stale configuration in the target storage.
+    foreach (array_merge([StorageInterface::DEFAULT_COLLECTION], $target->getAllCollectionNames()) as $collection) {
+      $target->createCollection($collection)->deleteAll();
+    }
+
+    // Copy all the configuration from all the collections.
+    foreach (array_merge([StorageInterface::DEFAULT_COLLECTION], $source->getAllCollectionNames()) as $collection) {
+      $source_collection = $source->createCollection($collection);
+      $target_collection = $target->createCollection($collection);
+      foreach ($source_collection->listAll() as $name) {
+        $data = $source_collection->read($name);
+        if ($data !== FALSE) {
+          $target_collection->write($name, $data);
+        }
+        else {
+          \Drupal::logger('config')->notice('Missing required data for configuration: %config', [
+            '%config' => $name,
+          ]);
+        }
+      }
+    }
+
+    // Make sure that the target is set to the same collection as the source.
+    $target = $target->createCollection($source->getCollectionName());
+  }
+
 }
-- 
GitLab