PEAR_ERROR_CALLBACK, '_PEAR_default_error_options' => $callback, 'modeException' => $modeException, ]; return new CRM_Core_TemporaryErrorScope($newFrame); } /** * @param $newFrame */ public function __construct($newFrame) { self::$oldFrames[] = self::getActive(); self::setActive($newFrame); } public function __destruct() { $oldFrame = array_pop(self::$oldFrames); self::setActive($oldFrame); } /** * Read the active error-handler settings */ public static function getActive() { return [ '_PEAR_default_error_mode' => $GLOBALS['_PEAR_default_error_mode'], '_PEAR_default_error_options' => $GLOBALS['_PEAR_default_error_options'], 'modeException' => CRM_Core_Error::$modeException, ]; } /** * Set the active error-handler settings * * @param string $frame */ public static function setActive($frame) { $GLOBALS['_PEAR_default_error_mode'] = $frame['_PEAR_default_error_mode']; $GLOBALS['_PEAR_default_error_options'] = $frame['_PEAR_default_error_options']; CRM_Core_Error::$modeException = $frame['modeException']; } }