diff --git a/.travis.yml b/.travis.yml index e3ec86b86..e25381f95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -70,6 +70,7 @@ jobs: allow_failures: - stage: Static Analysis (informative) - stage: Code Coverage + - php: 7.4snapshot sudo: false diff --git a/readme.md b/readme.md index aad616e70..d16a668fc 100644 --- a/readme.md +++ b/readme.md @@ -384,6 +384,22 @@ services: ``` +nginx +----- + +If Tracy does not work on nginx, it is probably misconfigured. If there is something like + +```nginx +try_files $uri $uri/ /index.php; +``` + +change it to + +```nginx +try_files $uri $uri/ /index.php$is_args$args; +``` + + Ports ----- diff --git a/src/Bridges/Nette/Bridge.php b/src/Bridges/Nette/Bridge.php index da9c04f27..423b04f76 100644 --- a/src/Bridges/Nette/Bridge.php +++ b/src/Bridges/Nette/Bridge.php @@ -47,7 +47,6 @@ public static function renderLatteError(?\Throwable $e): ?array . BlueScreen::highlightLine(htmlspecialchars($e->sourceCode, ENT_IGNORE, 'UTF-8'), $e->sourceLine) . '', ]; - } elseif ($e && strpos($file = $e->getFile(), '.latte--')) { $lines = file($file); if (preg_match('#// source: (\S+\.latte)#', $lines[1], $m) && @is_file($m[1])) { // @ - may trigger error @@ -94,7 +93,8 @@ public static function renderMemberAccessException(?\Throwable $e): ?array 'link' => Helpers::editorUri($loc['file'], $loc['line'], 'fix', '->' . $m[1], '->' . $m[2]), 'label' => 'fix it', ]; - } elseif (preg_match('#Call to undefined (static )?method .+::(\w+)\(\), did you mean (\w+)\(\)?#A', $e->getMessage(), $m)) { + } + if (preg_match('#Call to undefined (static )?method .+::(\w+)\(\), did you mean (\w+)\(\)?#A', $e->getMessage(), $m)) { $operator = $m[1] ? '::' : '->'; return [ 'link' => Helpers::editorUri($loc['file'], $loc['line'], 'fix', $operator . $m[2] . '(', $operator . $m[3] . '('), diff --git a/src/Tracy/Bar/assets/bar.css b/src/Tracy/Bar/assets/bar.css index 990bff727..7ef98db5d 100644 --- a/src/Tracy/Bar/assets/bar.css +++ b/src/Tracy/Bar/assets/bar.css @@ -95,7 +95,7 @@ body#tracy-debug { /* in popup window */ } #tracy-debug tr:nth-child(2n) td { - background: #F7F0CB; + background: #00000005; } #tracy-debug td, diff --git a/src/Tracy/BlueScreen/BlueScreen.php b/src/Tracy/BlueScreen/BlueScreen.php index abcf63812..1bc09d551 100644 --- a/src/Tracy/BlueScreen/BlueScreen.php +++ b/src/Tracy/BlueScreen/BlueScreen.php @@ -113,23 +113,8 @@ public function renderToFile(\Throwable $exception, string $file): bool private function renderTemplate(\Throwable $exception, string $template, $toScreen = true): void { - $messageHtml = Dumper::encodeString((string) $exception->getMessage(), self::MAX_MESSAGE_LENGTH); - $messageHtml = htmlspecialchars($messageHtml, ENT_SUBSTITUTE, 'UTF-8'); - $messageHtml = preg_replace( - '#\'\S(?:[^\']|\\\\\')*\S\'|"\S(?:[^"]|\\\\")*\S"#', - '$0', - $messageHtml - ); - $messageHtml = preg_replace_callback( - '#\w+\\\\[\w\\\\]+\w#', - function ($m) { - return class_exists($m[0], false) || interface_exists($m[0], false) - ? '' . $m[0] . '' - : $m[0]; - }, - $messageHtml - ); - + $showEnvironment = strpos($exception->getMessage(), 'Allowed memory size') === false; + $messageHtml = $this->formatMessage($exception); $info = array_filter($this->info); $source = Helpers::getSource(); $title = $exception instanceof \ErrorException @@ -384,4 +369,47 @@ public function getDumper(): \Closure ]); }; } + + + private function formatMessage(\Throwable $exception): string + { + $msg = Dumper::encodeString((string) $exception->getMessage(), self::MAX_MESSAGE_LENGTH); + $msg = htmlspecialchars($msg, ENT_SUBSTITUTE, 'UTF-8'); + + // highlight 'string' + $msg = preg_replace( + '#\'\S(?:[^\']|\\\\\')*\S\'|"\S(?:[^"]|\\\\")*\S"#', + '$0', + $msg + ); + + // clickable class & methods + $msg = preg_replace_callback( + '#(\w+\\\\[\w\\\\]+\w)(?:::(\w+))?#', + function ($m) { + if (isset($m[2]) && method_exists($m[1], $m[2])) { + $r = new \ReflectionMethod($m[1], $m[2]); + } elseif (class_exists($m[1], false) || interface_exists($m[1], false)) { + $r = new \ReflectionClass($m[1]); + } else { + return $m[0]; + } + return '' . $m[0] . ''; + }, + $msg + ); + + // clickable file name + $msg = preg_replace_callback( + '#([\w\\\\/.:-]+\.(?:php|phpt|phtml|latte|neon))(?|:(\d+)| on line (\d+))?#', + function ($m) { + return @is_file($m[1]) + ? '' . $m[0] . '' + : $m[0]; + }, + $msg + ); + + return $msg; + } } diff --git a/src/Tracy/BlueScreen/assets/content.phtml b/src/Tracy/BlueScreen/assets/content.phtml index d039539ba..5b2c78ed0 100644 --- a/src/Tracy/BlueScreen/assets/content.phtml +++ b/src/Tracy/BlueScreen/assets/content.phtml @@ -207,6 +207,7 @@ $code = $exception->getCode() ? ' #' . $exception->getCode() : ''; +