Drupal log shows that this module is causing the following error...

The error is
Message - Invalid argument supplied for foreach() in /homepages/1/d118711144/htdocs/blog/modules/statistics_filter/statistics_filter.module on line 73.
Severity - error

This error occurs immediately after a user login fails. i.e. the following error always precedes the aforementioned error:
Message - Login attempt failed for somebody@example.com : Sorry. Unrecognized username or password. Have you forgotten your password?.
Severity - notice

I am not 100% sure but I am positive that I did not get these errors in the original version of the module (I am using the updated version right now)

Thanks.

Comments

john.money’s picture

Confirmed... this error is happening because array_key_exists is being passed a haystack that is not an array when no filtered roles are set. Here is the fix (also changed array_key_exists to isset, which is much faster):

    $filtered_roles = variable_get('statistics_filter_roles', FALSE);
+    if (is_array($filtered_roles)) {
      $filtered_roles = array_flip($filtered_roles);
      foreach ($user->roles as $key => $value) {
+        if (isset($filtered_roles[$key])) { //use isset, much faster
-	//if (array_key_exists($key, $filtered_roles)) { 
          $do_filtering = TRUE;
          break;
        }
      }
    }
mikeryan’s picture

Version: » 4.6.x-1.x-dev
Assigned: Unassigned » mikeryan

Thanks for catching that - I've applied the fix to DRUPAL-4-6 (I'm no longer maintaining 4.5).

mikeryan’s picture