Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.12

Bug #7097 writeConfig incorrect when root has attributes
Submitted: 2006-03-12 09:55 UTC
From: farell Assigned: aharvey
Status: Closed Package: Config (version 1.10.6)
PHP Version: 4.4.2 OS: Windows XP
Roadmaps: (Not assigned)    
Subscription  


 [2006-03-12 09:55 UTC] farell (Laurent Laville)
Description: ------------ When trying to deal with multiple configuration structures, such as : <section1> <directive1>value1</directive1> </section1> <section2> <directive2>value2</directive2> </section2> or <virtualRoot> <section1> <directive1>value1</directive1> </section1> <section2> <directive2>value2</directive2> </section2> </virtualRoot> that has or not a virtual root, i found a problem with PHPArray container and root attributes. Here is a script to explain conditions and results: I'm expected to have at least same output than input. I hope it's not a normal behavior ! BTW, it works well if we give a virtual root in data source such as: $test['conf']['@']['version'] = '1.0'; $test['conf']['pfm']['roles']['php'] = 'php'; $test['conf']['pfm']['roles']['*'] = 'data'; Test script: --------------- <?php require_once 'Config.php'; $test['@']['version'] = '1.0'; $test['pfm']['roles']['php'] = 'php'; $test['pfm']['roles']['*'] = 'data'; $conf = new Config(); $root =& $conf->parseConfig($test, 'phparray', array('name' => 'test')); $conf->writeConfig($_ENV['TMP'] . DIRECTORY_SEPARATOR . 'writeConf.php', 'phparray', array('name' => 'test') ); echo '<pre>'. $root->toString('phparray', array('name' => 'test')) .'</pre>'; $attrs = $root->getAttributes(); echo '<pre>'; var_dump($attrs); echo '</pre>'; ?> Expected result: ---------------- $test['@']['version'] = '1.0'; $test['pfm']['roles']['php'] = 'php'; $test['pfm']['roles']['*'] = 'data'; array(1) { ["version"]=> string(3) "1.0" } Actual result: -------------- ['@']['version'] = '1.0'; $test['pfm']['roles']['php'] = 'php'; $test['pfm']['roles']['*'] = 'data'; array(1) { ["version"]=> string(3) "1.0" }

Comments

 [2006-10-20 03:02 UTC] aharvey at optimiser dot com (Adam Harvey)
The patch at http://www.adamharvey.name/patches/Config-phparray-getParentString.patch should fix this, although it will need to be checked that it doesn't break BC in any case with the PHPArray container, since I don't personally use it.
 [2006-10-20 03:28 UTC] aashley at php dot net (Adam Ashley)
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/Config