FIX: Don’t double-include composer autoloader

If another file is include main.php and has included composer already,
code might get weird. In particular, if the parent context includes a
different vendor/autoload.php than the one main.php expects.
This commit is contained in:
Sam Minnee 2016-09-12 17:26:31 +12:00
parent 93a0122c0f
commit 6b640f81f2

View File

@ -57,7 +57,8 @@ if (version_compare(phpversion(), '5.5.0', '<')) {
* @see Director::direct()
*/
// require composers autoloader
// require composers autoloader, unless it is already installed
if(!class_exists('Composer\\Autoload\\ClassLoader', false)) {
if (file_exists($autoloadPath = dirname(__DIR__) . '/vendor/autoload.php')) {
require_once $autoloadPath;
}
@ -69,6 +70,7 @@ else {
echo "Failed to include composer's autoloader, unable to continue\n";
exit(1);
}
}
// IIS will sometimes generate this.
if(!empty($_SERVER['HTTP_X_ORIGINAL_URL'])) {