Issue #1785560 by sun, alexpott, tim.plunkett, andypost: Remove the sorting of configuration keys.
parent
4c4b4a79cb
commit
fe77630a7c
|
@ -346,7 +346,6 @@ class Config {
|
|||
* The configuration object.
|
||||
*/
|
||||
public function save() {
|
||||
$this->sortByKey($this->data);
|
||||
$this->storage->write($this->name, $this->data);
|
||||
$this->isNew = FALSE;
|
||||
$this->notify('save');
|
||||
|
@ -369,26 +368,6 @@ class Config {
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts all keys in configuration data.
|
||||
*
|
||||
* Ensures that re-inserted keys appear in the same location as before, in
|
||||
* order to ensure an identical order regardless of storage controller.
|
||||
* A consistent order is important for any storage that allows any kind of
|
||||
* diff operation.
|
||||
*
|
||||
* @param array $data
|
||||
* An associative array to sort recursively by key name.
|
||||
*/
|
||||
public function sortByKey(array &$data) {
|
||||
ksort($data);
|
||||
foreach ($data as &$value) {
|
||||
if (is_array($value)) {
|
||||
$this->sortByKey($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the configuration object.
|
||||
*
|
||||
|
|
|
@ -92,30 +92,4 @@ class ConfigCRUDTest extends WebTestBase {
|
|||
$this->assertIdentical($renamed_config->isNew(), FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Drupal\Core\Config\Config::sortByKey().
|
||||
*/
|
||||
function testDataKeySort() {
|
||||
$config = config('config_test.keysort');
|
||||
$config->set('new', 'Value to be replaced');
|
||||
$config->set('static', 'static');
|
||||
$config->save();
|
||||
// Clone this Config, so this test does not rely on any particular
|
||||
// architecture.
|
||||
$config = clone $config;
|
||||
|
||||
// Load the configuration data into a new object.
|
||||
$new_config = config('config_test.keysort');
|
||||
// Clear the 'new' key that came first.
|
||||
$new_config->clear('new');
|
||||
// Add a new 'new' key and save.
|
||||
$new_config->set('new', 'Value to be replaced');
|
||||
$new_config->save();
|
||||
|
||||
// Verify that the data of both objects is in the identical order.
|
||||
// assertIdentical() is the required essence of this test; it performs a
|
||||
// strict comparison, which means that keys and values must be identical and
|
||||
// their order must be identical.
|
||||
$this->assertIdentical($new_config->get(), $config->get());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,10 +128,10 @@ class ConfigImportTest extends WebTestBase {
|
|||
$staging->write($name, $original_name_data);
|
||||
$original_dynamic_data = array(
|
||||
'id' => 'new',
|
||||
'label' => 'New',
|
||||
'langcode' => 'und',
|
||||
'style' => '',
|
||||
'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651',
|
||||
'label' => 'New',
|
||||
'style' => '',
|
||||
'langcode' => 'und',
|
||||
);
|
||||
$staging->write($dynamic_name, $original_dynamic_data);
|
||||
$this->assertIdentical($staging->exists($name), TRUE, $name . ' found.');
|
||||
|
|
Loading…
Reference in New Issue