ソースを参照

ZF-6773: Zend_Config_Writer_Xml creates fatal error

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@18187 44c647ce-9c0f-0410-b52a-842ac1e357ba
jan 16 年 前
コミット
d850128f3a
2 ファイル変更24 行追加2 行削除
  1. 1 1
      library/Zend/Config/Writer/Xml.php
  2. 23 1
      tests/Zend/Config/Writer/XmlTest.php

+ 1 - 1
library/Zend/Config/Writer/Xml.php

@@ -184,7 +184,7 @@ class Zend_Config_Writer_Xml extends Zend_Config_Writer
 
             if ($branchType === 'numeric') {
                 if ($value instanceof Zend_Config) {
-                    $child = $parent->addChild($branchName, (string) $value);
+                    $child = $parent->addChild($branchName);
 
                     $this->_addBranch($value, $child, $parent);
                 } else {

+ 23 - 1
tests/Zend/Config/Writer/XmlTest.php

@@ -150,7 +150,29 @@ class Zend_Config_Writer_XmlTest extends PHPUnit_Framework_TestCase
         $this->assertEquals('false', $config->staging->debug);
         $this->assertEquals(null, @$config->production);
     }
-    
+
+    /**
+     * @group ZF-6773
+     */
+    public function testWriteMultidimensionalArrayWithNumericKeys()
+    {
+        $writer = new Zend_Config_Writer_Xml;
+        $writer->write($this->_tempName, new Zend_Config(array(
+            'notification' => array(
+                'adress' => array(
+                    0 => array(
+                        'name' => 'Matthew',
+                        'mail' => 'matthew@example.com'
+                    ),
+                    1 => array(
+                        'name' => 'Thomas',
+                        'mail' => 'thomas@example.com'
+                    )
+                )
+            )
+        )));
+    }
+
     public function testNumericArray()
     {
         $config = new Zend_Config(array('foo' => array('bar' => array(1 => 'a', 2 => 'b', 5 => 'c'))));