Permalink
Browse files

Allow libphutil autoload to coexist with other autoload

Summary: If we fail to autoload we currently throw, but this breaks in the
presence of other autoloaders. Detect if there are other autoloaders and allow
them a chance to autoload.

Test Plan: Used PHPExcel to export excel documents (PHPExcel registers a
separate autoloader).

Reviewers: btrahan, jungejason

Reviewed By: btrahan

CC: aran, epriestley

Maniphest Tasks: T911

Differential Revision: https://secure.phabricator.com/D1747
  • Loading branch information...
1 parent 3276ad7 commit dbed7d749caecd1a5de31d55758073e7f83da61d @epriestley epriestley committed Mar 2, 2012
Showing with 15 additions and 1 deletion.
  1. +3 −0 .gitignore
  2. +12 −1 src/__phutil_library_init__.php
View
@@ -25,3 +25,6 @@ parser.yacc.output
# This file overrides "default.pem" if present.
/resources/ssl/custom.pem
+
+# arc sratch directory.
+/.arc/
@@ -289,7 +289,18 @@ public function getNewPath() {
* @group library
*/
function __phutil_autoload($class) {
- PhutilSymbolLoader::loadClass($class);
+ try {
+ PhutilSymbolLoader::loadClass($class);
+ } catch (PhutilMissingSymbolException $ex) {
+ // If there are other SPL autoloaders installed, we need to give them a
+ // chance to load the class. Throw the exception if we're the last
+ // autoloader; if not, swallow it and let them take a shot.
+ $autoloaders = spl_autoload_functions();
+ $last = end($autoloaders);
+ if ($last == '__phutil_autoload') {
+ throw $ex;
+ }
+ }
}
spl_autoload_register('__phutil_autoload', $throw = true);

0 comments on commit dbed7d7

Please sign in to comment.