-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Whoops displaying error page if there is PHP core warning or error (
#980)
- Loading branch information
Showing
3 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* @package Grav.Common.Errors | ||
* | ||
* @copyright Copyright (C) 2014 - 2016 RocketTheme, LLC. All rights reserved. | ||
* @license MIT License; see LICENSE file for details. | ||
*/ | ||
|
||
namespace Grav\Common\Errors; | ||
|
||
class SystemFacade extends \Whoops\Util\SystemFacade | ||
{ | ||
protected $whoopsShutdownHandler; | ||
|
||
/** | ||
* @param callable $function | ||
* | ||
* @return void | ||
*/ | ||
public function registerShutdownFunction(callable $function) | ||
{ | ||
$this->whoopsShutdownHandler = $function; | ||
register_shutdown_function([$this, 'handleShutdown']); | ||
} | ||
|
||
/** | ||
* Special case to deal with Fatal errors and the like. | ||
*/ | ||
public function handleShutdown() | ||
{ | ||
$error = $this->getLastError(); | ||
|
||
// Ignore core warnings and errors. | ||
if ($error && !($error['type'] & (E_CORE_WARNING | E_CORE_ERROR))) { | ||
$handler = $this->whoopsShutdownHandler; | ||
$handler(); | ||
} | ||
} | ||
} |