Re: [fw-general] BUG? Zend_Config_Xml

2007-11-04 Thread PotatoBob

*bump*
-- 
View this message in context: 
http://www.nabble.com/BUG--Zend_Config_Xml-tf4704756s16154.html#a13576486
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] BUG? Zend_Config_Xml

2007-10-27 Thread PotatoBob

It appears that there is a bug in Zend_Config_Xml when using it without
specific sections ($conf = new Zend_Config_Xml('file.xml', null);).

Since the _toArray() function does not check if the simplexmlobject only
contains a string, an empty Zend_Config obj is returned.
This only happens on the 2nd level element in the xml files as specifying
null in will use the first level elements to extend from.

Examples:

application
home../application/home
namespace
foofoo/foo
/namespace
/application

$conf-home will return an empty Zend_Config obj not the expected string.
$conf-namespace-foo will return as expected a string.

I simply added an if else to check if the simplexmlobject has children, if
not then return the string.

Zend_Config_Xml
/**
 * Returns an associative and possibly multidimensional array from a
SimpleXMLElement.
 *
 * @param SimpleXMLElement $xmlObject
 * @return array
 */
protected function _toArray($xmlObject)
{
$config = array();
if ($xmlObject-children()) {
foreach ($xmlObject-children() as $key = $value) {
if ($value-children()) {
$config[$key] = $this-_toArray($value);
} else {
$config[$key] = (string) $value;
}
}
} else {
$config = (string) $xmlObject;
}

return $config;
}

-- 
View this message in context: 
http://www.nabble.com/BUG--Zend_Config_Xml-tf4704756s16154.html#a13448031
Sent from the Zend Framework mailing list archive at Nabble.com.