Home » Configuration » Config » Bug #7695
Bug in ParseConfig
Details
| Submitted | 2006-05-22 15:18 UTC |
|---|---|
| From | mike at powerondude dot com |
| Assigned | aashley |
| Status | Bogus |
| Package | Config |
| PHP Version | 5.1.4 |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2006-05-22 15:18 UTC] mike at powerondude dot com
Description:
------------
There appears to be a bug in Config / parseConfig. Using an XML storage container, it allows you to create sections with spaces in it, but when reading that config back in with parseConfig, it will throw an exception in XML_Parse.
To use the example, take the space out between "Mikes" and "Laptop" and it will not throw the exception.
Test script:
---------------
<?php
require_once 'Config.php';
$c = new Config();
$Section =& new Config_Container("section", "Config");
$Server =& $Section->CreateSection("Servers");
$Rad= & $Server->createSection("Mikes Laptop");
$Rad->createDirective("port", "9000");
$Rad->createDirective("mgmtport", "8000");
$c->setRoot($Section);
$c->writeConfig("test.xml", "XML");
$testconfig = new Config();
$root = $testconfig->parseConfig("test.xml", "XML");
$TENConfig=($root->toArray());
var_dump($TENConfig);
?>
Expected result:
----------------
It should either throw an error on writing the XML file with the space or the parser should handle the space on reading the file back in.
Actual result:
--------------
Fatal error: Call to undefined method XML_Parser_Error::toArray() in /var/www/html/xmltest.php on line 21
[2006-05-22 15:27 UTC] mike at powerondude dot com
Just to reclassify the bug under the config package.
[2006-05-30 05:54 UTC] aashley at php dot net
Sorry, but your problem does not imply a bug in PEAR itself. For a
list of more appropriate places to ask for help using PEAR, please
visit http://pear.php.net/support/ as this bug system is not the
appropriate forum for asking support questions.
Thank you for your interest in PEAR.
Try adding some error handling to your test. The fatal error is because you are treating a returned error object as a valid config object.
Also won't be changing the behaviour of config to arbatarily modify data submitted to it. Spaces in section titles are allowed in some containers (Ini) and not in others (Apache, XML). It is up to the user to use it properly.