Skip to content
Snippets Groups Projects
Commit fe77630a authored by catch's avatar catch
Browse files

Issue #1785560 by sun, alexpott, tim.plunkett, andypost: Remove the sorting of configuration keys.

parent 4c4b4a79
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -346,7 +346,6 @@ public function load() {
* 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 @@ public function rename($new_name) {
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 @@ function testCRUD() {
$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 @@ function testNew() {
$staging->write($name, $original_name_data);
$original_dynamic_data = array(
'id' => 'new',
'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651',
'label' => 'New',
'langcode' => 'und',
'style' => '',
'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651',
'langcode' => 'und',
);
$staging->write($dynamic_name, $original_dynamic_data);
$this->assertIdentical($staging->exists($name), TRUE, $name . ' found.');
......
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