Skip to content

Commit 4c76dc4

Browse files
Izumi-kunsamdark
authored andcommitted
Fix #16610: ErrorException trace was cut when using XDebug
1 parent e7e72e2 commit 4c76dc4

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

framework/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Yii Framework 2 Change Log
1111
- Enh #16826: `appendTimestamp` support was added to `View` methods `registerCssFile()` and `registerJsFile()` (onmotion)
1212
- Enh #15526: Show valid aliases and options on invalid input in console application (samdark)
1313
- Bug #16671: Logging in `Connection::open()` was not respecting `Connection::$enableLogging` (samdark)
14+
- Bug #16610: ErrorException trace was cut when using XDebug (Izumi-kun)
1415

1516

1617
2.0.26 September 03, 2019

framework/base/ErrorException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct($message = '', $code = 0, $severity = 1, $filename =
4747
if (function_exists('xdebug_get_function_stack')) {
4848
// XDebug trace can't be modified and used directly with PHP 7
4949
// @see https://github.com/yiisoft/yii2/pull/11723
50-
$xDebugTrace = array_slice(array_reverse(xdebug_get_function_stack()), 3, -1);
50+
$xDebugTrace = array_slice(array_reverse(xdebug_get_function_stack()), 1, -1);
5151
$trace = [];
5252
foreach ($xDebugTrace as $frame) {
5353
if (!isset($frame['function'])) {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* @link http://www.yiiframework.com/
4+
* @copyright Copyright (c) 2008 Yii Software LLC
5+
* @license http://www.yiiframework.com/license/
6+
*/
7+
8+
namespace yiiunit\framework\base;
9+
10+
use yii\base\ErrorException;
11+
use yiiunit\TestCase;
12+
13+
/**
14+
* @group base
15+
*/
16+
class ErrorExceptionTest extends TestCase
17+
{
18+
public function testXdebugTrace()
19+
{
20+
if (!function_exists('xdebug_get_function_stack')) {
21+
$this->markTestSkipped('Xdebug are required.');
22+
}
23+
try {
24+
throw new ErrorException();
25+
} catch (ErrorException $e){
26+
$this->assertEquals(__FUNCTION__, $e->getTrace()[0]['function']);
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)