Skip to content
Snippets Groups Projects
Commit d1d5adf6 authored by Michael Lee's avatar Michael Lee
Browse files

Merge branch 'config_filter' into lee5151

parents 2a60eb64 4af9bb6b
No related branches found
No related tags found
No related merge requests found
......@@ -2459,17 +2459,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"
......@@ -2480,8 +2480,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"
......
......@@ -2539,18 +2539,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"
......@@ -2561,8 +2561,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"
......
......@@ -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(
......
......@@ -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
......@@ -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
......@@ -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
......@@ -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'));
......
......@@ -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());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment