Commit d5876f34 authored by xjm's avatar xjm
Browse files

Issue #3026386 by dsnopek, samuel.mortenson, xjm, ydahi, alexpott, Fabianx,...

Issue #3026386 by dsnopek, samuel.mortenson, xjm, ydahi, alexpott, Fabianx, kferencz91, littlepixiez, greggles, cilefen: Drush fatal error after upgrading to 8.6.6, 8.5.9, or 7.62: PHP Fatal error:  Uncaught TYPO3PharStreamWrapperException

(cherry picked from commit a5613263)
parent 7e1a53c1
...@@ -22,7 +22,6 @@ class PharExtensionInterceptor implements Assertable { ...@@ -22,7 +22,6 @@ class PharExtensionInterceptor implements Assertable {
* *
* @param string $path * @param string $path
* The path of the phar file to check. * The path of the phar file to check.
*
* @param string $command * @param string $command
* The command being carried out. * The command being carried out.
* *
...@@ -46,6 +45,8 @@ public function assert($path, $command) { ...@@ -46,6 +45,8 @@ public function assert($path, $command) {
} }
/** /**
* Determines if a path has a .phar extension or invoked execution.
*
* @param string $path * @param string $path
* The path of the phar file to check. * The path of the phar file to check.
* *
...@@ -62,8 +63,13 @@ private function baseFileContainsPharExtension($path) { ...@@ -62,8 +63,13 @@ private function baseFileContainsPharExtension($path) {
// not not have .phar extension then this should be allowed. For // not not have .phar extension then this should be allowed. For
// example, some CLI tools recommend removing the extension. // example, some CLI tools recommend removing the extension.
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$caller = array_pop($backtrace); // Find the last entry in the backtrace containing a 'file' key as
if (isset($caller['file']) && $baseFile === $caller['file']) { // sometimes the last caller is executed outside the scope of a file. For
// example, this occurs with shutdown functions.
do {
$caller = array_pop($backtrace);
} while (empty($caller['file']) && !empty($backtrace));
if (isset($caller['file']) && $baseFile === Helper::determineBaseFile($caller['file'])) {
return TRUE; return TRUE;
} }
$fileExtension = pathinfo($baseFile, PATHINFO_EXTENSION); $fileExtension = pathinfo($baseFile, PATHINFO_EXTENSION);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment