Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
315
Merge Requests
315
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
c98eebe4
Commit
c98eebe4
authored
Oct 09, 2012
by
catch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1807058
by sun: Fixed Config stores a NULL value as an array.
parent
fe77630a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
core/lib/Drupal/Core/Config/Config.php
core/lib/Drupal/Core/Config/Config.php
+4
-3
core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php
.../config/lib/Drupal/config/Tests/ConfigFileContentTest.php
+6
-0
No files found.
core/lib/Drupal/Core/Config/Config.php
View file @
c98eebe4
...
...
@@ -270,13 +270,14 @@ public function set($key, $value) {
* Any non-scalar value that is not an array (aka objects) gets cast
* to an array.
*
* @param $value
* @param
mixed
$value
* A value being saved into the configuration system.
* @param $value
*
* @return string
* The value cast to a string or array.
*/
public
function
castValue
(
$value
)
{
if
(
is_scalar
(
$value
))
{
if
(
is_scalar
(
$value
)
||
$value
===
NULL
)
{
// Handle special case of FALSE, which should be '0' instead of ''.
if
(
$value
===
FALSE
)
{
$value
=
'0'
;
...
...
core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php
View file @
c98eebe4
...
...
@@ -84,6 +84,9 @@ function testReadWriteConfig() {
// Add a boolean true value. Should get cast to 1
$config
->
set
(
$true_key
,
TRUE
);
// Add a null value. Should get cast to an empty string.
$config
->
set
(
'null'
,
NULL
);
// Add an array with a nested boolean false that should get cast to 0.
$config
->
set
(
$casting_array_key
,
$casting_array_value
);
$config
->
save
();
...
...
@@ -119,6 +122,9 @@ function testReadWriteConfig() {
// Read true value
$this
->
assertEqual
(
$config
->
get
(
$true_key
),
'1'
,
format_string
(
"Boolean TRUE value returned the string '1'."
));
// Read null value.
$this
->
assertIdentical
(
$config
->
get
(
'null'
),
''
);
// Read false that had been nested in an array value
$this
->
assertEqual
(
$config
->
get
(
$casting_array_false_value_key
),
'0'
,
format_string
(
"Nested boolean FALSE value returned the string '0'."
));
...
...
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