Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
drupal
Commits
c999c2d4
Commit
c999c2d4
authored
Oct 23, 2014
by
catch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2227731
by webflo, mtift: Fixed Normalize configuration data during config writes.
parent
5e154f01
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
10 deletions
+48
-10
core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php
core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php
+1
-4
core/modules/config/src/Tests/ConfigEntityNormalizeTest.php
core/modules/config/src/Tests/ConfigEntityNormalizeTest.php
+41
-0
core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php
...upal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php
+6
-6
No files found.
core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php
View file @
c999c2d4
...
...
@@ -250,10 +250,7 @@ protected function doSave($id, EntityInterface $entity) {
}
// Retrieve the desired properties and set them in config.
$record
=
$this
->
mapToStorageRecord
(
$entity
);
foreach
(
$record
as
$key
=>
$value
)
{
$config
->
set
(
$key
,
$value
);
}
$config
->
setData
(
$this
->
mapToStorageRecord
(
$entity
));
$config
->
save
();
return
$is_new
?
SAVED_NEW
:
SAVED_UPDATED
;
...
...
core/modules/config/src/Tests/ConfigEntityNormalizeTest.php
0 → 100644
View file @
c999c2d4
<?php
namespace
Drupal\config\Tests
;
use
Drupal\simpletest\KernelTestBase
;
/**
* Tests the listing of configuration entities.
*
* @group config
*/
class
ConfigEntityNormalizeTest
extends
KernelTestBase
{
public
static
$modules
=
array
(
'config_test'
);
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
installConfig
(
static
::
$modules
);
}
public
function
testNormalize
()
{
$config_entity
=
entity_create
(
'config_test'
,
array
(
'id'
=>
'system'
,
'label'
=>
'foobar'
,
'weight'
=>
1
));
$config_entity
->
save
();
// Modify stored config entity, this is comparable with a schema change.
$config
=
\
Drupal
::
config
(
'config_test.dynamic.system'
);
$data
=
array
(
'label'
=>
'foobar'
,
'additional_key'
=>
TRUE
)
+
$config
->
getRawData
();
$config
->
setData
(
$data
)
->
save
();
$this
->
assertNotIdentical
(
$config_entity
->
toArray
(),
$config
->
getRawData
(),
'Stored config entity is not is equivalent to config schema.'
);
$config_entity
=
entity_load
(
'config_test'
,
'system'
,
TRUE
);
$config_entity
->
save
();
$config
=
\
Drupal
::
config
(
'config_test.dynamic.system'
);
$this
->
assertIdentical
(
$config_entity
->
toArray
(),
$config
->
getRawData
(),
'Stored config entity is equivalent to config schema.'
);
}
}
core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php
View file @
c999c2d4
...
...
@@ -235,8 +235,8 @@ public function testSaveInsert(EntityInterface $entity) {
$config_object
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'isNew'
)
->
will
(
$this
->
returnValue
(
TRUE
));
$config_object
->
expects
(
$this
->
exactly
(
3
))
->
method
(
'set'
);
$config_object
->
expects
(
$this
->
exactly
(
1
))
->
method
(
'set
Data
'
);
$config_object
->
expects
(
$this
->
once
())
->
method
(
'save'
);
...
...
@@ -294,8 +294,8 @@ public function testSaveUpdate(EntityInterface $entity) {
$config_object
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'isNew'
)
->
will
(
$this
->
returnValue
(
FALSE
));
$config_object
->
expects
(
$this
->
exactly
(
3
))
->
method
(
'set'
);
$config_object
->
expects
(
$this
->
exactly
(
1
))
->
method
(
'set
Data
'
);
$config_object
->
expects
(
$this
->
once
())
->
method
(
'save'
);
...
...
@@ -354,8 +354,8 @@ public function testSaveRename(ConfigEntityInterface $entity) {
$config_object
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'isNew'
)
->
will
(
$this
->
returnValue
(
FALSE
));
$config_object
->
expects
(
$this
->
exactly
(
3
))
->
method
(
'set'
);
$config_object
->
expects
(
$this
->
exactly
(
1
))
->
method
(
'set
Data
'
);
$config_object
->
expects
(
$this
->
once
())
->
method
(
'save'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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