Zend Framework

class_exists call causing autoload in bootstrapabstract

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: 1.8.1
  • Fix Version/s: 1.8.1
  • Component/s: Zend_Application
  • Labels:
    None

Description

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:

$autoloader->suppressNotFoundWarnings(false);

as they are not on by default (another bug)

This was created by the fix for:
http://framework.zend.com/issues/browse/ZF-6543

Activity

Hide
Matthew Weier O'Phinney added a comment -

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.

Show
Matthew Weier O'Phinney added a comment - 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.
Hide
Jason Eisenmenger added a comment -

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.

Show
Jason Eisenmenger added a comment - 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.
Hide
Matthew Weier O'Phinney added a comment -

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.

Show
Matthew Weier O'Phinney added a comment - 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.
Hide
Matthew Weier O'Phinney added a comment -

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.

Show
Matthew Weier O'Phinney added a comment - 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.
Hide
Ben Scholzen added a comment -

Matthew, the actual issue was caused by this revision:
http://framework.zend.com/code/changelog/Zend_Framework?cs=15439

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

Show
Ben Scholzen added a comment - Matthew, the actual issue was caused by this revision: http://framework.zend.com/code/changelog/Zend_Framework?cs=15439 There's actually no bug in 1.8.0 but in the next mini release.
Hide
Matthew Weier O'Phinney added a comment -

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

Show
Matthew Weier O'Phinney added a comment - Loading resource plugins should no longer raise an exception on trunk or 1.8 release branch.
Hide
Jason Eisenmenger added a comment -

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}"

Show
Jason Eisenmenger added a comment - 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}"
Hide
Matthew Weier O'Phinney added a comment -

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

Show
Matthew Weier O'Phinney added a comment - This should now be resolved in trunk and the 1.8 release branch. whew!

People

Vote (1)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: