Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
b525d9c7
Commit
b525d9c7
authored
May 26, 2013
by
resurtm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed stack trace bug and added class/method call information.
parent
2516176e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
12 deletions
+38
-12
ErrorHandler.php
framework/yii/base/ErrorHandler.php
+19
-4
callStackItem.php
framework/yii/views/errorHandler/callStackItem.php
+16
-6
main.php
framework/yii/views/errorHandler/main.php
+3
-2
No files found.
framework/yii/base/ErrorHandler.php
View file @
b525d9c7
...
@@ -149,6 +149,13 @@ class ErrorHandler extends Component
...
@@ -149,6 +149,13 @@ class ErrorHandler extends Component
$html
.=
'<a href="http://yiiframework.com/doc/api/2.0/'
.
$this
->
htmlEncode
(
$part
)
.
'" target="_blank">'
.
$this
->
htmlEncode
(
$part
)
.
'</a>\\'
;
$html
.=
'<a href="http://yiiframework.com/doc/api/2.0/'
.
$this
->
htmlEncode
(
$part
)
.
'" target="_blank">'
.
$this
->
htmlEncode
(
$part
)
.
'</a>\\'
;
}
}
$html
=
rtrim
(
$html
,
'\\'
);
$html
=
rtrim
(
$html
,
'\\'
);
}
elseif
(
strpos
(
$code
,
'()'
)
!==
false
)
{
// method/function call
$self
=
$this
;
$html
=
preg_replace_callback
(
'/^(.*)\(\)$/'
,
function
(
$matches
)
use
(
$self
)
{
return
'<a href="http://yiiframework.com/doc/api/2.0/'
.
$this
->
htmlEncode
(
$matches
[
1
])
.
'" target="_blank">'
.
$self
->
htmlEncode
(
$matches
[
1
])
.
'</a>()'
;
},
$code
);
}
}
return
$html
;
return
$html
;
}
}
...
@@ -184,13 +191,18 @@ class ErrorHandler extends Component
...
@@ -184,13 +191,18 @@ class ErrorHandler extends Component
/**
/**
* Renders a single call stack element.
* Renders a single call stack element.
* @param string $file name where call has happened.
* @param string|null $file name where call has happened.
* @param integer $line number on which call has happened.
* @param integer|null $line number on which call has happened.
* @param string|null $class called class name.
* @param string|null $method called function/method name.
* @param integer $index number of the call stack element.
* @param integer $index number of the call stack element.
* @return string HTML content of the rendered call stack element.
* @return string HTML content of the rendered call stack element.
*/
*/
public
function
renderCallStackItem
(
$file
,
$line
,
$index
)
public
function
renderCallStackItem
(
$file
,
$line
,
$
class
,
$method
,
$
index
)
{
{
$lines
=
array
();
$begin
=
$end
=
0
;
if
(
$file
!==
null
&&
$line
!==
null
)
{
$line
--
;
// adjust line number from one-based to zero-based
$line
--
;
// adjust line number from one-based to zero-based
$lines
=
@
file
(
$file
);
$lines
=
@
file
(
$file
);
if
(
$line
<
0
||
$lines
===
false
||
(
$lineCount
=
count
(
$lines
))
<
$line
+
1
)
{
if
(
$line
<
0
||
$lines
===
false
||
(
$lineCount
=
count
(
$lines
))
<
$line
+
1
)
{
...
@@ -200,11 +212,14 @@ class ErrorHandler extends Component
...
@@ -200,11 +212,14 @@ class ErrorHandler extends Component
$half
=
(
int
)((
$index
==
0
?
$this
->
maxSourceLines
:
$this
->
maxTraceSourceLines
)
/
2
);
$half
=
(
int
)((
$index
==
0
?
$this
->
maxSourceLines
:
$this
->
maxTraceSourceLines
)
/
2
);
$begin
=
$line
-
$half
>
0
?
$line
-
$half
:
0
;
$begin
=
$line
-
$half
>
0
?
$line
-
$half
:
0
;
$end
=
$line
+
$half
<
$lineCount
?
$line
+
$half
:
$lineCount
-
1
;
$end
=
$line
+
$half
<
$lineCount
?
$line
+
$half
:
$lineCount
-
1
;
}
$view
=
new
View
();
$view
=
new
View
();
return
$view
->
renderFile
(
$this
->
callStackItemView
,
array
(
return
$view
->
renderFile
(
$this
->
callStackItemView
,
array
(
'file'
=>
$file
,
'file'
=>
$file
,
'line'
=>
$line
,
'line'
=>
$line
,
'class'
=>
$class
,
'method'
=>
$method
,
'index'
=>
$index
,
'index'
=>
$index
,
'lines'
=>
$lines
,
'lines'
=>
$lines
,
'begin'
=>
$begin
,
'begin'
=>
$begin
,
...
@@ -219,7 +234,7 @@ class ErrorHandler extends Component
...
@@ -219,7 +234,7 @@ class ErrorHandler extends Component
*/
*/
public
function
isCoreFile
(
$file
)
public
function
isCoreFile
(
$file
)
{
{
return
$file
===
'unknown'
||
strpos
(
realpath
(
$file
),
YII_PATH
.
DIRECTORY_SEPARATOR
)
===
0
;
return
$file
===
null
||
strpos
(
realpath
(
$file
),
YII_PATH
.
DIRECTORY_SEPARATOR
)
===
0
;
}
}
/**
/**
...
...
framework/yii/views/errorHandler/callStackItem.php
View file @
b525d9c7
<?php
<?php
/**
/**
* @var \yii\base\View $this
* @var \yii\base\View $this
* @var string $file
* @var string|null $file
* @var integer $line
* @var integer|null $line
* @var string|null $class
* @var string|null $method
* @var integer $index
* @var integer $index
* @var string[] $lines
* @var string[] $lines
* @var integer $begin
* @var integer $begin
...
@@ -11,15 +13,22 @@
...
@@ -11,15 +13,22 @@
*/
*/
$context
=
$this
->
context
;
$context
=
$this
->
context
;
?>
?>
<li
class=
"
<?php
if
(
!
$context
->
isCoreFile
(
$file
))
echo
'application'
;
?>
call-stack-item"
>
<li
class=
"
<?php
if
(
!
$context
->
isCoreFile
(
$file
)
||
$index
===
1
)
echo
'application'
;
?>
call-stack-item"
>
<div
class=
"element-wrap"
>
<div
class=
"element-wrap"
>
<div
class=
"element"
>
<div
class=
"element"
>
<span
class=
"number"
>
<?php
echo
(
int
)
$index
;
?>
.
</span>
<span
class=
"number"
>
<?php
echo
(
int
)
$index
;
?>
.
</span>
<span
class=
"text"
>
in
<?php
echo
$context
->
htmlEncode
(
$file
);
?>
</span>
<span
class=
"text"
>
<?php
if
(
$file
!==
null
)
echo
'in '
.
$context
->
htmlEncode
(
$file
);
?>
</span>
<span
class=
"at"
>
at line
</span>
<?php
if
(
$method
!==
null
)
:
?>
<span
class=
"line"
>
<?php
echo
(
int
)
$line
;
?>
</span>
<span
class=
"call"
>
<?php
if
(
$file
!==
null
)
echo
'–'
?>
<?php
if
(
$class
!==
null
)
echo
$context
->
addTypeLinks
(
$class
)
.
'→'
;
?><?php
echo
$context
->
addTypeLinks
(
$method
.
'()'
);
?>
</span>
<?php
endif
;
?>
<span
class=
"at"
>
<?php
if
(
$line
!==
null
)
echo
'at line'
;
?>
</span>
<span
class=
"line"
>
<?php
if
(
$line
!==
null
)
echo
(
int
)
$line
;
?>
</span>
</div>
</div>
</div>
</div>
<?php
if
(
!
empty
(
$lines
))
:
?>
<div
class=
"code-wrap"
>
<div
class=
"code-wrap"
>
<div
class=
"error-line"
style=
"top:
<?php
echo
18
*
(
int
)(
$line
-
$begin
);
?>
px;"
></div>
<div
class=
"error-line"
style=
"top:
<?php
echo
18
*
(
int
)(
$line
-
$begin
);
?>
px;"
></div>
<?php
for
(
$i
=
$begin
;
$i
<=
$end
;
++
$i
)
:
?>
<?php
for
(
$i
=
$begin
;
$i
<=
$end
;
++
$i
)
:
?>
...
@@ -30,4 +39,5 @@ $context = $this->context;
...
@@ -30,4 +39,5 @@ $context = $this->context;
<pre>
<?php
for
(
$i
=
$begin
;
$i
<=
$end
;
++
$i
)
echo
$context
->
htmlEncode
(
$lines
[
$i
]);
?>
</pre>
<pre>
<?php
for
(
$i
=
$begin
;
$i
<=
$end
;
++
$i
)
echo
$context
->
htmlEncode
(
$lines
[
$i
]);
?>
</pre>
</div>
</div>
</div>
</div>
<?php
endif
;
?>
</li>
</li>
framework/yii/views/errorHandler/main.php
View file @
b525d9c7
...
@@ -364,9 +364,10 @@ pre .diff .change{
...
@@ -364,9 +364,10 @@ pre .diff .change{
<div
class=
"call-stack"
>
<div
class=
"call-stack"
>
<ul>
<ul>
<?php
echo
$context
->
renderCallStackItem
(
$exception
->
getFile
(),
$exception
->
getLine
(),
1
);
?>
<?php
echo
$context
->
renderCallStackItem
(
$exception
->
getFile
(),
$exception
->
getLine
(),
null
,
null
,
1
);
?>
<?php
for
(
$i
=
1
,
$trace
=
$exception
->
getTrace
(),
$length
=
count
(
$trace
);
$i
<
$length
;
++
$i
)
:
?>
<?php
for
(
$i
=
1
,
$trace
=
$exception
->
getTrace
(),
$length
=
count
(
$trace
);
$i
<
$length
;
++
$i
)
:
?>
<?php
echo
$context
->
renderCallStackItem
(
$trace
[
$i
][
'file'
],
$trace
[
$i
][
'line'
],
$i
+
1
);
?>
<?php
echo
$context
->
renderCallStackItem
(
@
$trace
[
$i
][
'file'
]
?:
null
,
@
$trace
[
$i
][
'line'
]
?:
null
,
@
$trace
[
$i
][
'class'
]
?:
null
,
@
$trace
[
$i
][
'function'
]
?:
null
,
$i
+
1
);
?>
<?php
endfor
;
?>
<?php
endfor
;
?>
</ul>
</ul>
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment