Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed boolean/integer BC break in Zend\Config\Writer\PhpArray #5569

Merged
merged 1 commit into from

2 participants

@michaelmoussa

I realized I accidentally broke BC with the readable format config array PR. This is a simple fix that will preserve the config value's datatype when it isn't a string.

See PR 5259

@michaelmoussa michaelmoussa Fixed boolean/integer BC break.
Booleans and integers were being inadvertently converted to strings when
saved in the config array. This preserves the datatype.
20b30b9
@michaelmoussa michaelmoussa referenced this pull request in zfcampus/zf-apigility-admin
Closed

Updated Apigility Admin to allow setting of the default API version #27

@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney [#5569] CS fixes
- elseif -> else if
8b8a2b2
@weierophinney weierophinney merged commit 20b30b9 into from
@weierophinney weierophinney was assigned
@michaelmoussa michaelmoussa deleted the branch
@weierophinney weierophinney commented on the diff
library/Zend/Config/Writer/PhpArray.php
((8 lines not shown))
$arrayString .= "'" . addslashes($value) . "',\n";
+ } else {
+ $arrayString .= $value . ",\n";
@weierophinney Owner

This case creates a new issue; null values now result in invalid configuration like this:

'some_key' => ,

I'm going to apply a patch shortly that fixes that situation.

Ah, sorry I missed that. Thanks for catching it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney [#5569] Handle null values properly
- Previous fix led to:
  ```php
  'null' => ,
  ```
- Fix properly echoes the null value:
  ```php
  'null' => null,
  ```
f0da59f
@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/5569-null' into develop
Additional fix for #5569
fdae81f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 30, 2013
  1. @michaelmoussa

    Fixed boolean/integer BC break.

    michaelmoussa authored
    Booleans and integers were being inadvertently converted to strings when
    saved in the config array. This preserves the datatype.
This page is out of date. Refresh to see the latest.
View
6 library/Zend/Config/Writer/PhpArray.php
@@ -78,8 +78,12 @@ protected function processIndented(array $config, array $arraySyntax, &$indentLe
}
} elseif (is_object($value)) {
$arrayString .= var_export($value, true) . ",\n";
- } else {
+ } else if (is_bool($value)) {
+ $arrayString .= ($value ? 'true' : 'false') . ",\n";
+ } elseif (is_string($value)) {
$arrayString .= "'" . addslashes($value) . "',\n";
+ } else {
+ $arrayString .= $value . ",\n";
@weierophinney Owner

This case creates a new issue; null values now result in invalid configuration like this:

'some_key' => ,

I'm going to apply a patch shortly that fixes that situation.

Ah, sorry I missed that. Thanks for catching it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
}
}
View
6 tests/ZendTest/Config/Writer/PhpArrayTest.php
@@ -35,7 +35,9 @@ public function testRender()
'test' => 'foo',
'bar' => array(0 => 'baz', 1 => 'foo'),
'emptyArray' => array(),
- 'object' => (object) array('foo' => 'bar')
+ 'object' => (object) array('foo' => 'bar'),
+ 'integer' => 123,
+ 'boolean' => false,
));
$configString = $this->writer->toString($config);
@@ -52,6 +54,8 @@ public function testRender()
$expected .= " 'object' => stdClass::__set_state(array(\n";
$expected .= " 'foo' => 'bar',\n";
$expected .= ")),\n";
+ $expected .= " 'integer' => 123,\n";
+ $expected .= " 'boolean' => false,\n";
$expected .= ");\n";
$this->assertEquals($expected, $configString);
Something went wrong with that request. Please try again.