Skip to content

Commit

Permalink
tweaked the deprecated error handler to actually display the deprecat…
Browse files Browse the repository at this point in the history
…ion message

I've also removed uninterested information (like the trigger_error stack
frame).
  • Loading branch information
fabpot committed Jan 20, 2013
1 parent 6923a48 commit 1ab48db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@

{% macro display_message(log_index, log) %}
{% if constant('Symfony\\Component\\HttpKernel\\Debug\\ErrorHandler::TYPE_DEPRECATION') == log.context.type|default(0) %}
DEPRECATION - Deprecated call in {{ log.context.file|format_file(log.context.line) }}.
DEPRECATION - {{ log.message }}
{% set id = 'sf-call-stack-' ~ log_index %}
<a href="#" onclick="Sfjs.toggle('{{ id }}', document.getElementById('{{ id }}-on'), document.getElementById('{{ id }}-off')); return false;">
<img class="toggle" id="{{ id }}-off" alt="-" src="data:image/gif;base64,R0lGODlhEgASAMQSANft94TG57Hb8GS44ez1+mC24IvK6ePx+Wa44dXs92+942e54o3L6W2844/M6dnu+P/+/l614P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABIALAAAAAASABIAQAVCoCQBTBOd6Kk4gJhGBCTPxysJb44K0qD/ER/wlxjmisZkMqBEBW5NHrMZmVKvv9hMVsO+hE0EoNAstEYGxG9heIhCADs=" style="display:none" />
<img class="toggle" id="{{ id }}-on" alt="+" src="data:image/gif;base64,R0lGODlhEgASAMQTANft99/v+Ga44bHb8ITG52S44dXs9+z1+uPx+YvK6WC24G+944/M6W28443L6dnu+Ge54v/+/l614P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABMALAAAAAASABIAQAVS4DQBTiOd6LkwgJgeUSzHSDoNaZ4PU6FLgYBA5/vFID/DbylRGiNIZu74I0h1hNsVxbNuUV4d9SsZM2EzWe1qThVzwWFOAFCQFa1RQq6DJB4iIQA7" style="display:inline" />
</a>
{% for index, call in log.context.stack if index > 0 %}
{% if index == 1 %}
{% for index, call in log.context.stack if index > 1 %}
{% if index == 2 %}
<ul class="sf-call-stack" id="{{ id }}" style="display: none">
{% endif %}
{% if call.class is defined %}
Expand Down
13 changes: 3 additions & 10 deletions src/Symfony/Component/HttpKernel/Debug/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,9 @@ public function handle($level, $message, $file, $line, $context)

if ($level & (E_USER_DEPRECATED | E_DEPRECATED)) {
if (null !== self::$logger) {
$deprecation = array(
'type' => self::TYPE_DEPRECATION,
'file' => $file,
'line' => $line,
'stack' => version_compare(PHP_VERSION, '5.4', '<')
? array_slice(debug_backtrace(false), 0, 10)
: debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10)
);

self::$logger->warning($message, $deprecation);
$stack = version_compare(PHP_VERSION, '5.4', '<') ? array_slice(debug_backtrace(false), 0, 10) : debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10);

self::$logger->warning($message, array('type' => self::TYPE_DEPRECATION, 'stack' => $stack));
}

return true;
Expand Down

0 comments on commit 1ab48db

Please sign in to comment.