php 8. Fixed undefined array key warnings.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Tue, 15 Jun 2021 18:13:46 +0000 (20:13 +0200)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Tue, 15 Jun 2021 18:13:46 +0000 (20:13 +0200)
includes/errors.inc
includes/session.inc

index 53587df6ed081b1489e162d77898d474e48f3ed6..a54abba810f3adf87d950d29f6c763dd6a5f81da 100644 (file)
@@ -57,7 +57,7 @@ function get_backtrace($html = false, $skip=0)
 //    display in message box.
 
 function error_handler($errno, $errstr, $file, $line) {
-    global $messages, $SysPrefs;
+    global $messages, $SysPrefs, $cur_error_level;
 
        // skip well known warnings we don't care about.
        // Please use restrainedly to not risk loss of important messages
@@ -74,16 +74,18 @@ function error_handler($errno, $errstr, $file, $line) {
 
        $bt = isset($SysPrefs) && $SysPrefs->go_debug>1 ? get_backtrace(true, 1) : array();
 
-       // error_reporting==0 when messages are set off with @ 
-       if ($errno & error_reporting()) {
-               // suppress duplicated errors
-               if (!in_array(array($errno, $errstr, $file, $line, @$bt), $messages))
-                       $messages[] = array($errno, $errstr, $file, $line, @$bt);
-       }
-       else if ($errno&~E_NOTICE && $errstr != '') { // log all not displayed messages 
-               $user = @$_SESSION["wa_current_user"]->loginname;
-               $context = isset($SysPrefs) && !$SysPrefs->db_ok ? '[before upgrade]' : '';
-               error_log(user_company() . ":$user:". basename($file) .":$line:$context $errstr");
+       // error_reporting!=cur_error_level when messages are set off with @ 
+       if ($cur_error_level == error_reporting()) {
+               if ($errno & $cur_error_level) {
+                       // suppress duplicated errors
+                       if (!in_array(array($errno, $errstr, $file, $line, @$bt), $messages))
+                               $messages[] = array($errno, $errstr, $file, $line, @$bt);
+               }
+               else if ($errno&~E_NOTICE && $errstr != '') { // log all not displayed messages 
+                       $user = @$_SESSION["wa_current_user"]->loginname;
+                       $context = isset($SysPrefs) && !$SysPrefs->db_ok ? '[before upgrade]' : '';
+                       error_log(user_company() . ":$user:". basename($file) .":$line:$context $errstr");
+               }
        }
        
     return true;
index bb061e435c541bf8554f545ab551f4b4f90f69f2..fe3c795321c322ffd92a564db9efe2dbac557ce9 100644 (file)
@@ -413,9 +413,11 @@ if ((!isset($SysPrefs->login_max_attempts)) || ($SysPrefs->login_max_attempts <
     $SysPrefs->login_max_attempts = 3; 
 
 if ($SysPrefs->go_debug > 0)
-       error_reporting(-1);
+       $cur_error_level = -1;
 else
-       error_reporting(E_USER_WARNING|E_USER_ERROR|E_USER_NOTICE);
+       $cur_error_level = E_USER_WARNING|E_USER_ERROR|E_USER_NOTICE;
+
+error_reporting($cur_error_level);
 ini_set("display_errors", "On");
 
 if ($SysPrefs->error_logfile != '') {