From 976942bfeb21e90c9111447ffc3b94117166de81 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 19 Sep 2023 14:48:04 +0200 Subject: [PATCH] is_file may trigger error [Closes #572] --- src/Tracy/BlueScreen/BlueScreen.php | 4 ++-- src/Tracy/BlueScreen/assets/section-lastMutedError.phtml | 2 +- src/Tracy/BlueScreen/assets/section-stack-callStack.phtml | 6 +++--- src/Tracy/BlueScreen/assets/section-stack-sourceFile.phtml | 2 +- src/Tracy/Dumper/Describer.php | 2 +- src/Tracy/Helpers.php | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Tracy/BlueScreen/BlueScreen.php b/src/Tracy/BlueScreen/BlueScreen.php index f2ff25a4c..acc1d6bc0 100644 --- a/src/Tracy/BlueScreen/BlueScreen.php +++ b/src/Tracy/BlueScreen/BlueScreen.php @@ -261,7 +261,7 @@ private function renderActions(\Throwable $ex): array $class = $m[2]; if ( !class_exists($class, false) && !interface_exists($class, false) && !trait_exists($class, false) - && ($file = Helpers::guessClassFile($class)) && !is_file($file) + && ($file = Helpers::guessClassFile($class)) && !@is_file($file) // @ - may trigger error ) { [$content, $line] = $this->generateNewFileContents($file, $class); $actions[] = [ @@ -273,7 +273,7 @@ private function renderActions(\Throwable $ex): array if (preg_match('# ([\'"])((?:/|[a-z]:[/\\\\])\w[^\'"]+\.\w{2,5})\1#i', $ex->getMessage(), $m)) { $file = $m[2]; - if (is_file($file)) { + if (@is_file($file)) { // @ - may trigger error $label = 'open'; $content = ''; $line = 1; diff --git a/src/Tracy/BlueScreen/assets/section-lastMutedError.phtml b/src/Tracy/BlueScreen/assets/section-lastMutedError.phtml index 7e5565f4a..a4f79f73c 100644 --- a/src/Tracy/BlueScreen/assets/section-lastMutedError.phtml +++ b/src/Tracy/BlueScreen/assets/section-lastMutedError.phtml @@ -19,7 +19,7 @@ if (!$lastError) {

:

Note: the last muted error may have nothing to do with the thrown exception.

- +

diff --git a/src/Tracy/BlueScreen/assets/section-stack-callStack.phtml b/src/Tracy/BlueScreen/assets/section-stack-callStack.phtml index fa94d4e51..c298edd19 100644 --- a/src/Tracy/BlueScreen/assets/section-stack-callStack.phtml +++ b/src/Tracy/BlueScreen/assets/section-stack-callStack.phtml @@ -21,10 +21,10 @@ if (!$stack) {
$row): ?> - +
- + inner-code @@ -42,7 +42,7 @@ if (!$stack) {
- +
diff --git a/src/Tracy/BlueScreen/assets/section-stack-sourceFile.phtml b/src/Tracy/BlueScreen/assets/section-stack-sourceFile.phtml index a678c2eab..a3d72e230 100644 --- a/src/Tracy/BlueScreen/assets/section-stack-sourceFile.phtml +++ b/src/Tracy/BlueScreen/assets/section-stack-sourceFile.phtml @@ -10,7 +10,7 @@ namespace Tracy; * @var int $expanded */ -$sourceOriginal = $file && is_file($file) ? [$file, $line] : null; +$sourceOriginal = $file && @is_file($file) ? [$file, $line] : null; // @ - may trigger error $sourceMapped = $sourceOriginal ? Debugger::mapSource($file, $line) : null; ?> diff --git a/src/Tracy/Dumper/Describer.php b/src/Tracy/Dumper/Describer.php index d974bfec2..fb32ae75c 100644 --- a/src/Tracy/Dumper/Describer.php +++ b/src/Tracy/Dumper/Describer.php @@ -381,7 +381,7 @@ private static function findLocation(): ?array break; } - if (isset($location['file'], $location['line']) && is_file($location['file'])) { + if (isset($location['file'], $location['line']) && @is_file($location['file'])) { // @ - may trigger error $lines = file($location['file']); $line = $lines[$location['line'] - 1]; return [ diff --git a/src/Tracy/Helpers.php b/src/Tracy/Helpers.php index 46fa9d6d2..a0f179fba 100644 --- a/src/Tracy/Helpers.php +++ b/src/Tracy/Helpers.php @@ -58,7 +58,7 @@ public static function editorUri( string $replace = '' ): ?string { - if (Debugger::$editor && $file && ($action === 'create' || is_file($file))) { + if (Debugger::$editor && $file && ($action === 'create' || @is_file($file))) { // @ - may trigger error $file = strtr($file, '/', DIRECTORY_SEPARATOR); $file = strtr($file, Debugger::$editorMapping); $search = str_replace("\n", PHP_EOL, $search);