From 1d8609573bf49bbeaafd36d2012c35b317ba98c2 Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Thu, 12 Jan 2012 00:24:46 +0000 Subject: [PATCH] Add option to mask known PHP warnings by pattern matching Useful to mask things like 'mysql has gone away' and method signature overrides --- source/lib/SihnonFramework/Main.class.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/source/lib/SihnonFramework/Main.class.php b/source/lib/SihnonFramework/Main.class.php index 2ecb101..8c00c7f 100644 --- a/source/lib/SihnonFramework/Main.class.php +++ b/source/lib/SihnonFramework/Main.class.php @@ -129,6 +129,23 @@ class SihnonFramework_Main { } public static function errorHandler($errno, $errstr, $errfile = '', $errline = 0, $errcontext = array()) { + + $ignore_patterns = array( + /* Really don't consider this to be a bug, and make extensive use of this in the plugin architecture */ + '/^Declaration of .* should be compatible with that of .*/', + + /* This error is already handled in Database, but the warning is still triggered by PHP */ + '/^PDO::__construct.*: MySQL server has gone away/', + ); + + foreach ($ignore_patterns as $pattern) { + if (preg_match($pattern, $errstr)) { + if (defined('Sihnon_MaskKnownErrors') && Sihnon_MaskKnownErrors) { + return false; + } + } + } + $severity = ''; switch ($errno) { case E_NOTICE: