Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Respect error_reporting() in error handler

Summary:
This changes couple of things:

# Errors are not converted to exceptions with `@`.
# It respects `error_reporting()`.
# It doesn't pass ignored errors to listener.

Test Plan: Didn't see tons of "unable to select [4]: Interrupted system call at [Future.php:147]" in DarkConsole.

Reviewers: epriestley, nh

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4254
  • Loading branch information...
commit 69161db9ed33291105d7274697ee79531f3070b3 1 parent b45eea9
vrana authored
Showing with 9 additions and 8 deletions.
  1. +9 −8 src/error/PhutilErrorHandler.php
View
17 src/error/PhutilErrorHandler.php
@@ -153,6 +153,15 @@ public static function hasInitialized() {
*/
public static function handleError($num, $str, $file, $line, $ctx) {
+ if ((error_reporting() & $num) == 0) {
+ // Respect the use of "@" to silence warnings: if this error was
+ // emitted from a context where "@" was in effect, the
+ // value returned by error_reporting() will be 0. This is the
+ // recommended way to check for this, see set_error_handler() docs
+ // on php.net.
+ return false;
+ }
+
// Convert typehint failures into exceptions.
if (preg_match('/^Argument (\d+) passed to (\S+) must be/', $str)) {
throw new InvalidArgumentException($str);
@@ -280,14 +289,6 @@ public static function dispatchErrorMessage($event, $value, $metadata) {
switch ($event) {
case PhutilErrorHandler::ERROR:
- if (error_reporting() === 0) {
- // Respect the use of "@" to silence warnings: if this error was
- // emitted from a context where "@" was in effect, the
- // value returned by error_reporting() will be 0. This is the
- // recommended way to check for this, see set_error_handler() docs
- // on php.net.
- break;
- }
$default_message = sprintf(
'[%s] ERROR %d: %s at [%s:%d]',
$timestamp,
Please sign in to comment.
Something went wrong with that request. Please try again.