From 48d3283636ddcc8c7c94514a2e770bdc90398a4c Mon Sep 17 00:00:00 2001 From: David Rodrigues Date: Mon, 12 Jun 2017 14:47:55 -0300 Subject: [PATCH 1/2] feature #23144 [Debug] Different trace message style on application code (rentalhost) --- .../Component/Debug/ExceptionHandler.php | 31 +++++++++++++++++-- .../Debug/Tests/ExceptionHandlerTest.php | 12 +++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Debug/ExceptionHandler.php b/src/Symfony/Component/Debug/ExceptionHandler.php index 5c399ef089e3b..624654aca2e4e 100644 --- a/src/Symfony/Component/Debug/ExceptionHandler.php +++ b/src/Symfony/Component/Debug/ExceptionHandler.php @@ -11,9 +11,11 @@ namespace Symfony\Component\Debug; +use Symfony\Component\Config\Resource\ReflectionClassResource; use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\Debug\Exception\OutOfMemoryException; use Symfony\Component\HttpKernel\Debug\FileLinkFormatter; +use Composer\Autoload\ClassLoader; /** * ExceptionHandler converts an exception to a Response object. @@ -233,11 +235,11 @@ public function getContent(FlattenException $exception) EOF , $ind, $total, $class, $message); foreach ($e['trace'] as $trace) { - $content .= ''; + $content .= ''; if ($trace['function']) { $content .= sprintf('at %s%s%s(%s)', $this->formatClass($trace['class']), $trace['type'], $trace['function'], $this->formatArgs($trace['args'])); } - if (isset($trace['file']) && isset($trace['line'])) { + if (isset($trace['file'], $trace['line'])) { $content .= $this->formatPath($trace['file'], $trace['line']); } $content .= "\n"; @@ -320,6 +322,8 @@ public function getStylesheet(FlattenException $exception) .trace-message { font-size: 14px; font-weight: normal; margin: .5em 0 0; } + .trace-row.application { background-color: #ffffe6; } + .trace-file-path, .trace-file-path a { margin-top: 3px; color: #999; color: #795da3; color: #B0413E; color: #222; font-size: 13px; } .trace-class { color: #B0413E; } .trace-type { padding: 0 2px; } @@ -411,4 +415,27 @@ private function getSymfonyGhostAsSvg() { return ''; } + + private static function getTraceClassname($trace) + { + if (empty($trace['file'])) { + return null; + } + + $vendorRoot = static::getVendorRoot(); + $traceFileRelative = str_replace($vendorRoot, '', $trace['file']); + + if (strpos($traceFileRelative, '\\vendor\\') === 0) { + return null; + } + + return 'application'; + } + + private static function getVendorRoot() + { + $classReflection = new \ReflectionClass(ClassLoader::class); + + return dirname($classReflection->getFileName(), 3); + } } diff --git a/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php b/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php index 0285eff1346cb..b033a328db79c 100644 --- a/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php @@ -130,4 +130,16 @@ public function testHandleOutOfMemoryException() $handler->handle($exception); } + + public function testApplicationStyle() + { + $handler = new ExceptionHandler(); + + ob_start(); + $handler->sendPhpResponse(new \RuntimeException('Foo')); + $response = ob_get_clean(); + + $this->assertSame(1, preg_match('/trace-row application".+ExceptionHandlerTest\\.php.+<\\/td>/', $response)); + $this->assertSame(1, preg_match('/trace-row ".+testApplicationStyle().+<\\/td>/', $response)); + } } From cfab90833c47bce52ea407b468302701dfcbfb5e Mon Sep 17 00:00:00 2001 From: David Rodrigues Date: Mon, 12 Jun 2017 15:39:37 -0300 Subject: [PATCH 2/2] Fixing code-style --- src/Symfony/Component/Debug/ExceptionHandler.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Debug/ExceptionHandler.php b/src/Symfony/Component/Debug/ExceptionHandler.php index 624654aca2e4e..154b96395ae41 100644 --- a/src/Symfony/Component/Debug/ExceptionHandler.php +++ b/src/Symfony/Component/Debug/ExceptionHandler.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Debug; -use Symfony\Component\Config\Resource\ReflectionClassResource; use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\Debug\Exception\OutOfMemoryException; use Symfony\Component\HttpKernel\Debug\FileLinkFormatter; @@ -235,7 +234,7 @@ public function getContent(FlattenException $exception) EOF , $ind, $total, $class, $message); foreach ($e['trace'] as $trace) { - $content .= ''; + $content .= ''; if ($trace['function']) { $content .= sprintf('at %s%s%s(%s)', $this->formatClass($trace['class']), $trace['type'], $trace['function'], $this->formatArgs($trace['args'])); } @@ -423,9 +422,9 @@ private static function getTraceClassname($trace) } $vendorRoot = static::getVendorRoot(); - $traceFileRelative = str_replace($vendorRoot, '', $trace['file']); + $traceFileRelative = str_replace($vendorRoot, '', realpath($trace['file'])); - if (strpos($traceFileRelative, '\\vendor\\') === 0) { + if (strpos($traceFileRelative, '/vendor/') === 0) { return null; } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy