Skip to content

Commit 025d732

Browse files
committed
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
1 parent 6736973 commit 025d732

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/Drupal/Core/Security/PharExtensionInterceptor.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class PharExtensionInterceptor implements Assertable {
2222
*
2323
* @param string $path
2424
* The path of the phar file to check.
25-
*
2625
* @param string $command
2726
* The command being carried out.
2827
*
@@ -46,6 +45,8 @@ public function assert($path, $command) {
4645
}
4746

4847
/**
48+
* Determines if a path has a .phar extension or invoked execution.
49+
*
4950
* @param string $path
5051
* The path of the phar file to check.
5152
*
@@ -62,8 +63,13 @@ private function baseFileContainsPharExtension($path) {
6263
// not not have .phar extension then this should be allowed. For
6364
// example, some CLI tools recommend removing the extension.
6465
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
65-
$caller = array_pop($backtrace);
66-
if (isset($caller['file']) && $baseFile === $caller['file']) {
66+
// Find the last entry in the backtrace containing a 'file' key as
67+
// sometimes the last caller is executed outside the scope of a file. For
68+
// example, this occurs with shutdown functions.
69+
do {
70+
$caller = array_pop($backtrace);
71+
} while (empty($caller['file']) && !empty($backtrace));
72+
if (isset($caller['file']) && $baseFile === Helper::determineBaseFile($caller['file'])) {
6773
return TRUE;
6874
}
6975
$fileExtension = pathinfo($baseFile, PATHINFO_EXTENSION);

0 commit comments

Comments
 (0)