Skip to content

Commit

Permalink
Fixes #13671: Fixed error handler trace to work correctly with XDebug
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark authored Mar 6, 2017
1 parent 3dcd8d5 commit a6d2664
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Yii Framework 2 Change Log
2.0.12 under development
--------------------------

- Bug #13671: Fixed error handler trace to work correctly with XDebug (samdark)
- Bug #13657: Fixed `yii\helpers\StringHelper::truncateHtml()` skip extra tags at the end (sam002)
- Bug #7946 Fixed a bug when the `form` attribute was not propagated to the hidden input of the checkbox (Kolyunya)
- Bug #13087: Fixed getting active validators for safe attribute (developeruz)
Expand Down
8 changes: 1 addition & 7 deletions framework/views/errorHandler/exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,7 @@
</div>

<div class="call-stack">
<ul>
<?= $handler->renderCallStackItem($exception->getFile(), $exception->getLine(), null, null, [], 1) ?>
<?php for ($i = 0, $trace = $exception->getTrace(), $length = count($trace); $i < $length; ++$i): ?>
<?= $handler->renderCallStackItem(@$trace[$i]['file'] ?: null, @$trace[$i]['line'] ?: null,
@$trace[$i]['class'] ?: null, @$trace[$i]['function'] ?: null, @$trace[$i]['args'] ?: [], $i + 2) ?>
<?php endfor; ?>
</ul>
<?= $handler->renderCallStack($exception) ?>
</div>

<div class="request">
Expand Down
24 changes: 24 additions & 0 deletions framework/web/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,30 @@ public function renderCallStackItem($file, $line, $class, $method, $args, $index
]);
}

/**
* Renders call stack.
* @param \Exception $exception exception to get call stack from
* @return string HTML content of the rendered call stack.
*/
public function renderCallStack(\Exception $exception)
{
$out = '<ul>';
$out .= $this->renderCallStackItem($exception->getFile(), $exception->getLine(), null, null, [], 1);
for ($i = 0, $trace = $exception->getTrace(), $length = count($trace); $i < $length; ++$i) {
$file = !empty($trace[$i]['file']) ? $trace[$i]['file'] : null;
$line = !empty($trace[$i]['line']) ? $trace[$i]['line'] : null;
$class = !empty($trace[$i]['class']) ? $trace[$i]['class'] : null;
$function = null;
if (!empty($trace[$i]['function']) && $trace[$i]['function'] !== 'unknown') {
$function = $trace[$i]['function'];
}
$args = !empty($trace[$i]['args']) ? $trace[$i]['args'] : [];
$out .= $this->renderCallStackItem($file, $line, $class, $function, $args, $i + 2);
}
$out .= '</ul>';
return $out;
}

/**
* Renders the global variables of the request.
* List of global variables is defined in [[displayVars]].
Expand Down

0 comments on commit a6d2664

Please sign in to comment.