Issues

ZF-9110: Recursion in Bootstrap

Issue Type: Bug Created: 2010-02-07T10:02:35.000+0000 Last Updated: 2010-02-08T08:45:24.000+0000 Status: Resolved Fix version(s): - 1.10.1 (10/Feb/10)

Reporter: Roy Fang (royfang) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Application

Related issues: Attachments:

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:

<pre class="highlight">
$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:

<pre class="highlight">
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.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts