Skip to content

Commit

Permalink
FIX BASE_PATH fallback assumed wrong file location (silverstripe#9977)
Browse files Browse the repository at this point in the history
The file was moved back in 2017 with silverstripe@3873e4b#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
  • Loading branch information
chillu authored and michalkleiner committed Aug 5, 2021
1 parent e0548b2 commit ac2864e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/includes/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@
}
}

// 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;
Expand Down

0 comments on commit ac2864e

Please sign in to comment.