Browse code

Fix PHP warning when array index for role does not exist

Hanno authored on21/06/2018 17:18:31
Showing1 changed files
... ...
@@ -165,11 +165,13 @@ function logger($severity, $scriptname, $scope, $message)
165 165
 
166 166
   DEBUG("LOGGING $scriptname:$scope:$message");
167 167
   $user = NULL;
168
-  if ($_SESSION['role'] & ROLE_SYSTEMUSER)
169
-    $user = $_SESSION['userinfo']['username'];
170
-  elseif ($_SESSION['role'] & ROLE_CUSTOMER)
171
-    $user = $_SESSION['customerinfo']['customerno'];
172
-  
168
+  if (array_key_exists("role", $_SESSION)) {
169
+    if ($_SESSION['role'] & ROLE_SYSTEMUSER)
170
+      $user = $_SESSION['userinfo']['username'];
171
+    elseif ($_SESSION['role'] & ROLE_CUSTOMER)
172
+      $user = $_SESSION['customerinfo']['customerno'];
173
+  }
174
+
173 175
   $args = array(":user" => $user,
174 176
                 ":remote" => $_SERVER['REMOTE_ADDR'],
175 177
                 ":scriptname" => $scriptname,