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
f72c451c
Commit
f72c451c
authored
Aug 02, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display debug toolbar on error pages.
parent
1398de3f
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
22 deletions
+29
-22
Application.php
framework/yii/base/Application.php
+2
-1
ErrorHandler.php
framework/yii/base/ErrorHandler.php
+5
-0
callStackItem.php
framework/yii/views/errorHandler/callStackItem.php
+5
-5
error.php
framework/yii/views/errorHandler/error.php
+11
-10
exception.php
framework/yii/views/errorHandler/exception.php
+0
-0
previousException.php
framework/yii/views/errorHandler/previousException.php
+6
-6
No files found.
framework/yii/base/Application.php
View file @
f72c451c
...
@@ -475,6 +475,8 @@ abstract class Application extends Module
...
@@ -475,6 +475,8 @@ abstract class Application extends Module
*/
*/
public
function
handleFatalError
()
public
function
handleFatalError
()
{
{
unset
(
$this
->
_memoryReserve
);
// load ErrorException manually here because autoloading them will not work
// load ErrorException manually here because autoloading them will not work
// when error occurs while autoloading a class
// when error occurs while autoloading a class
if
(
!
class_exists
(
'\\yii\\base\\Exception'
,
false
))
{
if
(
!
class_exists
(
'\\yii\\base\\Exception'
,
false
))
{
...
@@ -487,7 +489,6 @@ abstract class Application extends Module
...
@@ -487,7 +489,6 @@ abstract class Application extends Module
$error
=
error_get_last
();
$error
=
error_get_last
();
if
(
ErrorException
::
isFatalError
(
$error
))
{
if
(
ErrorException
::
isFatalError
(
$error
))
{
unset
(
$this
->
_memoryReserve
);
$exception
=
new
ErrorException
(
$error
[
'message'
],
$error
[
'type'
],
$error
[
'type'
],
$error
[
'file'
],
$error
[
'line'
]);
$exception
=
new
ErrorException
(
$error
[
'message'
],
$error
[
'type'
],
$error
[
'type'
],
$error
[
'file'
],
$error
[
'line'
]);
// use error_log because it's too late to use Yii log
// use error_log because it's too late to use Yii log
error_log
(
$exception
);
error_log
(
$exception
);
...
...
framework/yii/base/ErrorHandler.php
View file @
f72c451c
...
@@ -192,11 +192,16 @@ class ErrorHandler extends Component
...
@@ -192,11 +192,16 @@ class ErrorHandler extends Component
*/
*/
public
function
renderFile
(
$_file_
,
$_params_
)
public
function
renderFile
(
$_file_
,
$_params_
)
{
{
$_params_
[
'handler'
]
=
$this
;
if
(
$this
->
exception
instanceof
ErrorException
)
{
ob_start
();
ob_start
();
ob_implicit_flush
(
false
);
ob_implicit_flush
(
false
);
extract
(
$_params_
,
EXTR_OVERWRITE
);
extract
(
$_params_
,
EXTR_OVERWRITE
);
require
(
Yii
::
getAlias
(
$_file_
));
require
(
Yii
::
getAlias
(
$_file_
));
return
ob_get_clean
();
return
ob_get_clean
();
}
else
{
return
Yii
::
$app
->
getView
()
->
renderFile
(
$_file_
,
$_params_
,
$this
);
}
}
}
/**
/**
...
...
framework/yii/views/errorHandler/callStackItem.php
View file @
f72c451c
...
@@ -8,19 +8,19 @@
...
@@ -8,19 +8,19 @@
* @var string[] $lines
* @var string[] $lines
* @var integer $begin
* @var integer $begin
* @var integer $end
* @var integer $end
* @var \yii\base\ErrorHandler $
this
* @var \yii\base\ErrorHandler $
handler
*/
*/
?>
?>
<li
class=
"
<?php
if
(
!
$
this
->
isCoreFile
(
$file
)
||
$index
===
1
)
echo
'application'
;
?>
call-stack-item"
<li
class=
"
<?php
if
(
!
$
handler
->
isCoreFile
(
$file
)
||
$index
===
1
)
echo
'application'
;
?>
call-stack-item"
data-line=
"
<?php
echo
(
int
)(
$line
-
$begin
);
?>
"
>
data-line=
"
<?php
echo
(
int
)(
$line
-
$begin
);
?>
"
>
<div
class=
"element-wrap"
>
<div
class=
"element-wrap"
>
<div
class=
"element"
>
<div
class=
"element"
>
<span
class=
"item-number"
>
<?php
echo
(
int
)
$index
;
?>
.
</span>
<span
class=
"item-number"
>
<?php
echo
(
int
)
$index
;
?>
.
</span>
<span
class=
"text"
>
<?php
if
(
$file
!==
null
)
echo
'in '
.
$
this
->
htmlEncode
(
$file
);
?>
</span>
<span
class=
"text"
>
<?php
if
(
$file
!==
null
)
echo
'in '
.
$
handler
->
htmlEncode
(
$file
);
?>
</span>
<?php
if
(
$method
!==
null
)
:
?>
<?php
if
(
$method
!==
null
)
:
?>
<span
class=
"call"
>
<span
class=
"call"
>
<?php
if
(
$file
!==
null
)
echo
'–'
?>
<?php
if
(
$file
!==
null
)
echo
'–'
?>
<?php
if
(
$class
!==
null
)
echo
$
this
->
addTypeLinks
(
$class
)
.
'::'
;
?><?php
echo
$this
->
addTypeLinks
(
$method
.
'()'
);
?>
<?php
if
(
$class
!==
null
)
echo
$
handler
->
addTypeLinks
(
$class
)
.
'::'
;
?><?php
echo
$handler
->
addTypeLinks
(
$method
.
'()'
);
?>
</span>
</span>
<?php
endif
;
?>
<?php
endif
;
?>
<span
class=
"at"
>
<?php
if
(
$line
!==
null
)
echo
'at line'
;
?>
</span>
<span
class=
"at"
>
<?php
if
(
$line
!==
null
)
echo
'at line'
;
?>
</span>
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
<pre>
<?php
<pre>
<?php
// fill empty lines with a whitespace to avoid rendering problems in opera
// fill empty lines with a whitespace to avoid rendering problems in opera
for
(
$i
=
$begin
;
$i
<=
$end
;
++
$i
)
{
for
(
$i
=
$begin
;
$i
<=
$end
;
++
$i
)
{
echo
(
trim
(
$lines
[
$i
])
==
''
)
?
"
\n
"
:
$
this
->
htmlEncode
(
$lines
[
$i
]);
echo
(
trim
(
$lines
[
$i
])
==
''
)
?
"
\n
"
:
$
handler
->
htmlEncode
(
$lines
[
$i
]);
}
}
?>
</pre>
?>
</pre>
</div>
</div>
...
...
framework/yii/views/errorHandler/error.php
View file @
f72c451c
<?php
<?php
/**
/**
* @var \Exception $exception
* @var \Exception $exception
* @var \yii\base\ErrorHandler $
this
* @var \yii\base\ErrorHandler $
handler
*/
*/
$title
=
$
this
->
htmlEncode
(
$exception
instanceof
\yii\base\Exception
?
$exception
->
getName
()
:
get_class
(
$exception
));
$title
=
$
handler
->
htmlEncode
(
$exception
instanceof
\yii\base\Exception
?
$exception
->
getName
()
:
get_class
(
$exception
));
?>
?>
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
...
@@ -50,16 +50,17 @@ $title = $this->htmlEncode($exception instanceof \yii\base\Exception ? $exceptio
...
@@ -50,16 +50,17 @@ $title = $this->htmlEncode($exception instanceof \yii\base\Exception ? $exceptio
</head>
</head>
<body>
<body>
<h1>
<?php
echo
$title
?>
</h1>
<h1>
<?php
echo
$title
?>
</h1>
<h2>
<?php
echo
nl2br
(
$this
->
htmlEncode
(
$exception
->
getMessage
()))
?>
</h2>
<h2>
<?php
echo
nl2br
(
$handler
->
htmlEncode
(
$exception
->
getMessage
()))
?>
</h2>
<p>
<p>
The above error occurred while the Web server was processing your request.
The above error occurred while the Web server was processing your request.
</p>
</p>
<p>
<p>
Please contact us if you think this is a server error. Thank you.
Please contact us if you think this is a server error. Thank you.
</p>
</p>
<div
class=
"version"
>
<div
class=
"version"
>
<?php
echo
date
(
'Y-m-d H:i:s'
,
time
())
?>
<?php
echo
date
(
'Y-m-d H:i:s'
,
time
())
?>
</div>
</div>
<?php
if
(
method_exists
(
$this
,
'endBody'
))
$this
->
endBody
();
// to allow injecting code into body (mostly by Yii Debug Toolbar) ?>
</
body
>
</
body
>
</
html
>
</
html
>
framework/yii/views/errorHandler/exception.php
View file @
f72c451c
This diff is collapsed.
Click to expand it.
framework/yii/views/errorHandler/previousException.php
View file @
f72c451c
<?php
<?php
/**
/**
* @var \yii\base\Exception $exception
* @var \yii\base\Exception $exception
* @var \yii\base\ErrorHandler $
this
* @var \yii\base\ErrorHandler $
handler
*/
*/
?>
?>
<div
class=
"previous"
>
<div
class=
"previous"
>
...
@@ -9,13 +9,13 @@
...
@@ -9,13 +9,13 @@
<h2>
<h2>
<span>
Caused by:
</span>
<span>
Caused by:
</span>
<?php
if
(
$exception
instanceof
\yii\base\Exception
)
:
?>
<?php
if
(
$exception
instanceof
\yii\base\Exception
)
:
?>
<span>
<?php
echo
$
this
->
htmlEncode
(
$exception
->
getName
());
?>
</span>
–
<span>
<?php
echo
$
handler
->
htmlEncode
(
$exception
->
getName
());
?>
</span>
–
<?php
echo
$
this
->
addTypeLinks
(
get_class
(
$exception
));
?>
<?php
echo
$
handler
->
addTypeLinks
(
get_class
(
$exception
));
?>
<?php
else
:
?>
<?php
else
:
?>
<span>
<?php
echo
$
this
->
htmlEncode
(
get_class
(
$exception
));
?>
</span>
<span>
<?php
echo
$
handler
->
htmlEncode
(
get_class
(
$exception
));
?>
</span>
<?php
endif
;
?>
<?php
endif
;
?>
</h2>
</h2>
<h3>
<?php
echo
$
this
->
htmlEncode
(
$exception
->
getMessage
());
?>
</h3>
<h3>
<?php
echo
$
handler
->
htmlEncode
(
$exception
->
getMessage
());
?>
</h3>
<p>
in
<span
class=
"file"
>
<?php
echo
$exception
->
getFile
();
?>
</span>
at line
<span
class=
"line"
>
<?php
echo
$exception
->
getLine
();
?>
</span></p>
<p>
in
<span
class=
"file"
>
<?php
echo
$exception
->
getFile
();
?>
</span>
at line
<span
class=
"line"
>
<?php
echo
$exception
->
getLine
();
?>
</span></p>
<?php
echo
$
this
->
renderPreviousExceptions
(
$exception
);
?>
<?php
echo
$
handler
->
renderPreviousExceptions
(
$exception
);
?>
</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