FIX BASE_PATH fallback assumed wrong file location (#9977)

The file was moved back in 2017 with 3873e4ba00 (diff-8ce3f007bef0668c2c08320160362229abce9614025dc2a5b729d1b2b56ed3f7),
but the logic wasn't updated. That wasn't apparent since the fallback usually doesn't need to be triggered.
Whenever constants.php is included through the standard composer autoload, the debug_backtrace() logic took priority.

This is an important piece for using CoreKernel directly to boot Silverstripe,
which I'm currently attempting through a composer plugin (so a different autoloading path).
https://github.com/silverstripe/silverstripe-graphql-composer-plugin
This commit is contained in:
Ingo Schommer 2021-07-08 11:11:39 +12:00 committed by GitHub
parent 2e5908cf21
commit b2a85e7a02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,9 +58,10 @@ if (!defined('BASE_PATH')) {
}
}
// Determine BASE_PATH by assuming that this file is framework/src/Core/Constants.php
// we can then determine the base path
$candidateBasePath = rtrim(dirname(dirname(dirname(__DIR__))), DIRECTORY_SEPARATOR);
// Determine BASE_PATH by assuming that this file is vendor/silverstripe/framework/src/includes/constants.php
// we can then determine the base path
$candidateBasePath = rtrim(dirname(__DIR__, 5), DIRECTORY_SEPARATOR);
// We can't have an empty BASE_PATH. Making it / means that double-slashes occur in places but that's benign.
// This likely only happens on chrooted environemnts
return $candidateBasePath ?: DIRECTORY_SEPARATOR;