ZF-2240: Zend_Config_Xml can't find extended nodes (possibly only when empty)
Description
When using a file such as this:
<?xml version="1.0"?>
and loading it with Zend_Config_XML:
// Add Routes from config files $router = $front->getRouter(); $router->addConfig( new Zend_Config_Xml( 'config.xml', 'development' ), 'routes' );
it produces an exception: exception 'Zend_Controller_Router_Exception' with message 'No route configuration in section 'routes'' in /example/zend/library/Zend/Controller/Router/Rewrite.php:129
Running:
%svn update -r 6838 zend/library/Zend/Config
clears up the issue so the problem was introduced in revision 6906.
Looking at the source it my be due to the changes in the _toArray() method which assumes a node with no children is a string. My node has no children. Though this probably won't be the normal case I would think it should still work.
Comments
Posted by Jeffrey Sambells (jeffrey) on 2007-11-26T21:47:31.000+0000
Here's a patch to fix it.
Index: zend/library/Zend/Config/Xml.php
--- zend/library/Zend/Config/Xml.php (revision 6950) +++ zend/library/Zend/Config/Xml.php (working copy) @@ -140,8 +140,13 @@ } } } else { - // object has no children: it's a string - $config = (string) $xmlObject; + if(isset($xmlObject['extends'])) { + // object is empty but it extends so we still need to process it + $config[$key] = (string) $value; + } else { + // object has no children: it's a string + $config = (string) $xmlObject; + } } return $config; }
Posted by Jeffrey Sambells (jeffrey) on 2007-11-27T09:44:58.000+0000
This is a better patch. the last one causes NOTICE errors:
Index: zend/library/Zend/Config/Xml.php
--- zend/library/Zend/Config/Xml.php (revision 6950) +++ zend/library/Zend/Config/Xml.php (working copy) @@ -140,8 +140,11 @@ } } } else { - // object has no children: it's a string - $config = (string) $xmlObject; + // if the element extends then it isn't a string + if(!isset($xmlObject['extends'])) { + // object has no children and doesn't extend: it's a string + $config = (string) $xmlObject; + } } return $config; }
Posted by Rob Allen (rob) on 2007-11-27T14:14:21.000+0000
Sorry about that!
Fixed in svn r6965 on trunk and r6966 on release-1.0 branch.
Regards,
Rob...
Posted by Wil Sinclair (wil) on 2008-01-23T18:14:55.000+0000
Updating Fix Version to follow issue tracker conventions.