Index: library/Zend/Gdata/App.php =================================================================== --- library/Zend/Gdata/App.php (revision 24859) +++ library/Zend/Gdata/App.php (working copy) @@ -1060,6 +1060,9 @@ break; } catch (Zend_Exception $e) { // package wasn't here- continue searching + } catch (ErrorException $e) { + // package wasn't here- continue searching + // @see ZF-7013 and ZF-11959 } } if ($foundClassName != null) { Index: tests/Zend/Gdata/AppTest.php =================================================================== --- tests/Zend/Gdata/AppTest.php (revision 24859) +++ tests/Zend/Gdata/AppTest.php (working copy) @@ -584,4 +584,34 @@ $feed = $this->service->newFeed(); $this->assertEquals($v, $feed->getMinorProtocolVersion()); } + + /** + * When error handler is overridden to throw an ErrorException, the extension loader + * in Zend_Gdata will throw an ErrorException when the class doesn't exist in the + * first extension directory even if it exists in subsequent ones. This test + * enforces a fix that keeps this from happening + * + * @group ZF-12268 + * @group ZF-7013 + */ + public function testLoadExtensionCausesFatalErrorWhenErrorHandlerIsOverridden() + { + // Override the error handler to throw an ErrorException + set_error_handler(create_function('$a, $b, $c, $d', 'throw new ErrorException($b, 0, $a, $c, $d);'), E_ALL); + try { + $eq = $this->service->newEventQuery(); + restore_error_handler(); + $this->assertType('Zend_Gdata_Calendar_EventQuery', $eq); + } catch ( Zend_Gdata_App_Exception $ex ) { + // If we catch this exception, it means the ErrorException resulting + // from the include_once E_NOTICE was caught in the right place, + // but the extension was not found in any directory + // (Expected since we didn't load the Calendar extension dir) + restore_error_handler(); + $this->assertContains('EventQuery', $ex->getMessage()); + } catch ( ErrorException $ex ) { + restore_error_handler(); + $this->fail('Did not expect ErrorException'); + } + } }