ZF-9110: Recursion in Bootstrap
Description
For Zend_Application_Bootstrap_BootstrapAbstract::setApplication($application), the parameter $application could be type of Zend_Application or Zend_Application_Bootstrap_Bootstrapper. So following code would cause recursion:
$options = array(...);
$application = new Zend_Application(null, $options);
$bootstrap = $application->getBootstrap();
$bootstrap->setApplication($bootstrap); // set itself as its parent bootstrap
$bootstrap->getEnvironment(); // recursion on $this->getApplication()->getEnvironment()
The solution is:
public function setApplication($application)
{
if (($application instanceof Zend_Application)
|| ($application instanceof Zend_Application_Bootstrap_Bootstrapper)
) {
if ($application !== $this) { // test if $application equals to $this
$this->_application = $application;
} else { // throw an exception
throw new Zend_Application_Bootstrap_Exception('Set $this as its parent bootstrap');
}
} else {
throw new Zend_Application_Bootstrap_Exception(
'Invalid application provided to bootstrap constructor (received "'
. get_class($application) . '" instance)');
}
return $this;
}
Comments
Posted by Matthew Weier O'Phinney (matthew) on 2010-02-08T08:45:24.000+0000
Fixed in trunk and 1.10 release branch.