Fixed user config values unavailable error generated before user login
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Sun, 1 Oct 2017 21:03:41 +0000 (23:03 +0200)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Sun, 1 Oct 2017 21:03:41 +0000 (23:03 +0200)
includes/current_user.inc

index 239324c69dd0f304942fbc8980a88da21eb68afe..431cfefe2546cd90dbc56968a16578f4898208ea 100644 (file)
@@ -683,10 +683,12 @@ function array_append(&$array, $elements)
 //
 function array_search_value($needle, $haystack, $valuekey=null)
 {
-       foreach($haystack as $key => $value) {
-               $val = isset($valuekey) ? @$value[$valuekey] : $value;
-               if ($needle == $val){
-                       return $value;
+       if (is_array($haystack)) {
+               foreach($haystack as $key => $value) {
+                       $val = isset($valuekey) ? @$value[$valuekey] : $value;
+                       if ($needle == $val){
+                               return $value;
+                       }
                }
        }
        return null;
@@ -698,13 +700,14 @@ function array_search_value($needle, $haystack, $valuekey=null)
 function array_search_keys($needle, $haystack, $valuekey=null)
 {
        $keys = array();
-       if($haystack)
+       if (is_array($haystack)) {
                foreach($haystack as $key => $value) {
                        $val = isset($valuekey) ? @$value[$valuekey] : $value;
                        if ($needle == $val){
                                $keys[] = $key;
                        }
                }
+       }       
        return $keys;
 }
 //