ZF-6591: class_exists call causing autoload in bootstrapabstract

Issue Type: Bug Created: 2009-05-09T10:35:36.000+0000 Last Updated: 2009-05-12T05:35:27.000+0000 Status: Resolved Fix version(s): - 1.8.1 (12/May/09)

Reporter: Jason Eisenmenger (jasoneisen) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Application

Related issues: Attachments: - BootstrapAbstract.diff


the class_exists() method in BootstrapAbstract::registerPluginResource is launching the autoloader, and tries to include resources without the proper paths. The second parameter in this method should be false so that it doesn't launch the autoload.

Note, you need to do this to get the errors:


as they are not on by default (another bug)

This was created by the fix for:


Posted by Matthew Weier O'Phinney (matthew) on 2009-05-09T12:30:46.000+0000

Removing autoloading would break some functionality that was corrected, however. What is the exact problem?

The idea here is that if the class exists -- i.e., has been or can be autoloaded -- we need to treat it differently so as to ensure that it registers with the bootstrap correctly (which prevents naming collisions). If we do not allow class_exists() to attempt to autoload the class, then we lose this ability.

Is there an actual problem that occurs if autoloading fails to find the class? Or are you simply getting logged notices? You've marked the issue as "critical", but not really indicated what the issue is exactly.

Posted by Jason Eisenmenger (jasoneisen) on 2009-05-09T12:51:08.000+0000

Sorry, yes. When resources come through as stings, say 'frontController', the autoloader tries to load that class, which is not namespaced. If you have $autoloader->setFallbackAutoloader(true);, then it won't find it, obviously, and cause a fatality.

Posted by Matthew Weier O'Phinney (matthew) on 2009-05-09T17:22:13.000+0000

Aha -- so, what I'm hearing is that because the default internal autoloader does not do any exception handling, you're observing fatal errors due to uncaught exceptions. I think I know how to proceed from here -- but the solution is not to stop checking for classes, but to make a slight change to the autoloader so as to check for exceptions.

Posted by Matthew Weier O'Phinney (matthew) on 2009-05-09T17:24:22.000+0000

I've reviewed Zend_Loader_Autoloader, and I see why it behaves differently with suppressNotFoundWarnings enabled versus disabled: in the former case, it runs the try/catch block, while in the latter it does not. This is trivial to correct.

Posted by Ben Scholzen (dasprid) on 2009-05-09T17:30:10.000+0000

Matthew, the actual issue was caused by this revision:…

There's actually no bug in 1.8.0 but in the next mini release.

Posted by Matthew Weier O'Phinney (matthew) on 2009-05-09T17:44:29.000+0000

Loading resource plugins should no longer raise an exception on trunk or 1.8 release branch.

Posted by Jason Eisenmenger (jasoneisen) on 2009-05-11T08:44:01.000+0000

Now it crashes right out of the gate:

Warning: Zend_Loader::include(Bootstrap.php) [zend-loader.include]: failed to open stream: No such file or directory in /Users/Jason/Sites/quadrant/library/Zend/Loader.php on line 83

Warning: Zend_Loader::include() [function.include]: Failed opening 'Bootstrap.php' for inclusion (include_path='/Users/Jason/Sites/quadrant/application/../library:/Users/Jason/Sites/quadrant/application/../library/Doctrine:/Users/Jason/Sites/quadrant/application/library:/Users/Jason/Sites/quadrant/application/models:/Users/Jason/Sites/quadrant/application/models/generated:/Users/Jason/Sites/quadrant/library') in /Users/Jason/Sites/quadrant/library/Zend/Loader.php on line 83

string(925) "#0 [internal function]: Zend_Loader::loadClass('Bootstrap')

1 /Users/Jason/Sites/quadrant/library/Zend/Loader/Autoloader.php(443): call_user_func(Array, 'Bootstrap')

2 [internal function]: Zend_Loader_Autoloader->_autoload('Bootstrap')

3 /Users/Jason/Sites/quadrant/library/Zend/Loader/Autoloader.php(125): call_user_func(Array, 'Bootstrap')

4 [internal function]: Zend_Loader_Autoloader::autoload('Bootstrap')

5 [internal function]: spl_autoload_call('Bootstrap')

6 /Users/Jason/Sites/quadrant/library/Zend/Application.php(266): class_exists('Bootstrap')

7 /Users/Jason/Sites/quadrant/library/Zend/Application.php(156): Zend_Application->setBootstrap('/Users/Jason/Si...', 'Bootstrap')

8 /Users/Jason/Sites/quadrant/library/Zend/Application.php(85): Zend_Application->setOptions(Array)

9 /Users/Jason/Sites/quadrant/htdocs/index.php(45): Zend_Application->__construct('development', '/Users/Jason/Si...')

10 {main}"

Posted by Matthew Weier O'Phinney (matthew) on 2009-05-12T05:35:24.000+0000

This should now be resolved in trunk and the 1.8 release branch. whew!

Have you found an issue?

See the Overview section for more details.


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

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