Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit dbed7d749caecd1a5de31d55758073e7f83da61d 1 parent 3276ad7
@epriestley epriestley authored
Showing with 15 additions and 1 deletion.
  1. +3 −0  .gitignore
  2. +12 −1 src/__phutil_library_init__.php
View
3  .gitignore
@@ -25,3 +25,6 @@ parser.yacc.output
# This file overrides "default.pem" if present.
/resources/ssl/custom.pem
+
+# arc sratch directory.
+/.arc/
View
13 src/__phutil_library_init__.php
@@ -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);
Please sign in to comment.
Something went wrong with that request. Please try again.