Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
fe77630a
Commit
fe77630a
authored
Oct 09, 2012
by
Nathaniel Catchpole
Browse files
Issue
#1785560
by sun, alexpott, tim.plunkett, andypost: Remove the sorting of configuration keys.
parent
4c4b4a79
Changes
3
Hide whitespace changes
Inline
Side-by-side
core/lib/Drupal/Core/Config/Config.php
View file @
fe77630a
...
...
@@ -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.
*
...
...
core/modules/config/lib/Drupal/config/Tests/ConfigCRUDTest.php
View file @
fe77630a
...
...
@@ -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
());
}
}
core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php
View file @
fe77630a
...
...
@@ -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.'
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment