diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index d40f28587fda62047331764f1e1299531508ebfb..99e16c82b37c4479f0d67de07d1ce80907c58f3a 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -9,6 +9,25 @@ */ class SimpleSAML_Utilities { + /** + * List of log levels. + * + * This list is used to restore the log levels after some log levels are disabled. + * + * @var array + */ + private static $logLevelStack = array(); + + + /** + * The current mask of disabled log levels. + * + * Note: This mask is not directly related to the PHP error reporting level. + * + * @var int + */ + public static $logMask = 0; + /** * Will return sp.example.org @@ -2062,6 +2081,38 @@ class SimpleSAML_Utilities { return $tempDir; } + + /** + * Disable reporting of the given log levels. + * + * Every call to this function must be followed by a call to popErrorMask(); + * + * @param int $mask The log levels that should be masked. + */ + public static function maskErrors($mask) { + assert('is_int($mask)'); + + $currentEnabled = error_reporting(); + self::$logLevelStack[] = array($currentEnabled, self::$logMask); + + $currentEnabled &= ~$mask; + error_reporting($currentEnabled); + self::$logMask |= $mask; + } + + + /** + * Pop an error mask. + * + * This function restores the previous error mask. + */ + public static function popErrorMask() { + + $lastMask = array_pop(self::$logLevelStack); + error_reporting($lastMask[0]); + self::$logMask = $lastMask[1]; + } + } ?> \ No newline at end of file diff --git a/www/_include.php b/www/_include.php index 810f919d4af0e2f684d6a7918c84c03b097d4c29..2f67ef9740d9a34c37c114722f1b7c975974ae03 100644 --- a/www/_include.php +++ b/www/_include.php @@ -32,6 +32,11 @@ set_exception_handler('SimpleSAML_exception_handler'); /* Log full backtrace on errors and warnings. */ function SimpleSAML_error_handler($errno, $errstr, $errfile = NULL, $errline = 0, $errcontext = NULL) { + if ($errno & SimpleSAML_Utilities::$logMask) { + /* Masked error. */ + return FALSE; + } + static $limit = 5; $limit -= 1; if ($limit < 0) {