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
7f1f1b77
Commit
7f1f1b77
authored
Feb 20, 2013
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Moved handling fatal errors into handleFatalError() method.
- Refactored checking for fatal error. - Suppressed errors in exception handler in case of fatal errors.
parent
97eda21a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
9 deletions
+23
-9
Application.php
framework/base/Application.php
+15
-7
ErrorException.php
framework/base/ErrorException.php
+8
-2
No files found.
framework/base/Application.php
View file @
7f1f1b77
...
...
@@ -150,10 +150,22 @@ class Application extends Module
$this
->
afterRequest
();
}
$this
->
handleFatalError
();
if
(
$exit
)
{
exit
(
$status
);
}
}
/**
* Handles fatal PHP errors
*/
public
function
handleFatalError
()
{
if
(
YII_ENABLE_ERROR_HANDLER
)
{
$error
=
error_get_last
();
if
(
isset
(
$error
[
'type'
])
&&
in_array
(
$error
[
'type'
],
ErrorException
::
getFatalCodes
()
))
{
if
(
ErrorException
::
isFatalErorr
(
$error
))
{
unset
(
$this
->
_memoryReserve
);
$exception
=
new
ErrorException
(
$error
[
'message'
],
$error
[
'type'
],
$error
[
'type'
],
$error
[
'file'
],
$error
[
'line'
]);
...
...
@@ -184,18 +196,14 @@ class Application extends Module
$this
->
logException
(
$exception
);
if
((
$handler
=
$this
->
getErrorHandler
())
!==
null
)
{
$handler
->
handle
(
$exception
);
@
$handler
->
handle
(
$exception
);
}
else
{
$this
->
renderException
(
$exception
);
}
$status
=
1
;
exit
(
1
)
;
}
}
if
(
$exit
)
{
exit
(
$status
);
}
}
/**
...
...
framework/base/ErrorException.php
View file @
7f1f1b77
...
...
@@ -47,9 +47,15 @@ class ErrorException extends Exception
return
$this
->
severity
;
}
public
static
function
getFatalCodes
()
/**
* Returns if error is one of fatal type
*
* @param array $error error got from error_get_last()
* @return bool if error is one of fatal type
*/
public
static
function
isFatalErorr
(
$error
)
{
return
array
(
E_ERROR
,
E_PARSE
,
E_CORE_ERROR
,
E_CORE_WARNING
,
E_COMPILE_ERROR
,
E_COMPILE_WARNING
);
return
isset
(
$error
[
'type'
])
&&
in_array
(
$error
[
'type'
],
array
(
E_ERROR
,
E_PARSE
,
E_CORE_ERROR
,
E_CORE_WARNING
,
E_COMPILE_ERROR
,
E_COMPILE_WARNING
)
);
}
/**
...
...
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