fsf changes, meant to be rebased on upstream
[squirrelmail.git] / class / error.class.php
index 23a32d8c72a4cf6473f56a7176d1a0847d284c2a..b26104232c49f3ffdb7a7521b1ea8352be767f7a 100644 (file)
@@ -5,7 +5,7 @@
  *
  * This contains the custom error handler for SquirrelMail.
  *
- * @copyright © 2005-2006 The SquirrelMail Project Team
+ * @copyright 2005-2022 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
@@ -34,12 +34,12 @@ if (ini_get('docref_root')=='') ini_set('docref_root','http://www.php.net/');
 class ErrorHandler {
 
     /**
-     * Constructor
+     * Constructor (PHP5 style, required in some future version of PHP)
      * @param  object $oTemplate Template object
      * @param  string $sTemplateFile Template containing the error template
      * @since 1.5.1
      */
-    function ErrorHandler(&$oTemplate, $sTemplateFile) {
+    function __construct(&$oTemplate, $sTemplateFile) {
 #        echo 'init error handler...';
         $this->TemplateName = $sTemplateFile;
         $this->Template =& $oTemplate;
@@ -49,6 +49,16 @@ class ErrorHandler {
         $this->Template->assign('delayed_errors', $this->delayed_errors);
     }
 
+    /**
+     * Constructor (PHP4 style, kept for compatibility reasons)
+     * @param  object $oTemplate Template object
+     * @param  string $sTemplateFile Template containing the error template
+     * @since 1.5.1
+     */
+    function ErrorHandler(&$oTemplate, $sTemplateFile) {
+        self::__construct($oTemplate, $sTemplateFile);
+    }
+
     /**
      * Sets the error template
      * @since 1.5.1
@@ -94,7 +104,7 @@ class ErrorHandler {
      * @private
      * @since 1.5.1
      */
-    function SquirrelMailErrorhandler($iErrNo, $sErrStr, $sErrFile, $iErrLine, $aContext) {
+    function SquirrelMailErrorhandler($iErrNo, $sErrStr, $sErrFile, $iErrLine, $aContext=NULL) {
         $aError = array(
                         'type'     => SQM_NOTICE,// Error type, notice, warning or fatal error;
                         'category' => NULL,      // SquirrelMail error category;
@@ -177,7 +187,7 @@ class ErrorHandler {
                         }
                         if ($aError['category'] & SQM_ERROR_PLUGIN) {
                             $aErrorCategory[] = 'PLUGIN';
-                            do_hook_function('error_handler_plugin',$aError);
+                            do_hook('error_handler_plugin', $aError);
                             // plugin related error handling inside
                         }
                         //if ($aError['category'] & SQM_ERROR_X) {
@@ -220,7 +230,14 @@ class ErrorHandler {
         // Show the error immediate in case of fatal errors
         if ($iType == SQM_ERROR) {
             if (isset($this->Template->values['header_sent']) && !$this->Template->values['header_sent']) {
-                // TODO replace this with template that can be assigned
+// TODO replace this with template that can be assigned
+// UPDATE: displayHtmlHeader() no longer sends anything
+//         directly to the browser itself and instead 
+//         displays all output through the template file 
+//         "protocol_header" as well as calls to the 
+//         template's header() method, so perhaps the 
+//         above TODO is alleviated?? (however, I don't fully
+//         understand the problem behind the TODO comment myself (Paul))
                 displayHtmlHeader(_("Error"),'',false);
             }
             $this->DisplayErrors();
@@ -235,12 +252,10 @@ class ErrorHandler {
     function saveDelayedErrors () {
         if($this->delayed_errors) {
             // Check for previous delayed errors...
-            if (!$this->delayed_errors) {
-                sqgetGlobalVar('delayed_errors',  $delayed_errors,  SQ_SESSION);
-                if (is_array($delayed_errors)) {
-                    $this->AssignDelayedErrors($delayed_errors);
-                    sqsession_unregister("delayed_errors");
-                }
+            sqgetGlobalVar('delayed_errors',  $delayed_errors,  SQ_SESSION);
+            if (is_array($delayed_errors)) {
+                $this->AssignDelayedErrors($delayed_errors);
+                sqsession_unregister("delayed_errors");
             }
 
             if (count($this->aErrors) > 0) {