Problem/Motivation

A clean new installation of Drupal Commons 6.x-2.3 sitting on Drupal 6.22 is showing a pair of warnings on the first edit by the Admin of a new user's account information. The module.info file does not indicate the current version, thus 6.x-2.x.dev is assumed.

warning: array_filter() [function.array-filter]: The first argument should be an array in /profiles/drupal_commons/modules/contrib/activity_log/activity_log.user_settings.inc on line 63.

Line 63 of the code is as follows:

$values = array_filter($edit['activity_log_types']);

warning: Invalid argument supplied for foreach() in /profiles/drupal_commons/modules/contrib/activity_log/activity_log.user_settings.inc on line 66.

Line 66 of the code is as follows:

foreach ($all as $type) {

The function is as follows:

/**
 * Saves the form that allows disabling seeing certain activity types.
 */
function _activity_log_user_form_submit($edit) {
  $all = $edit['activity_log_types_all_values'];
  $disabled = $edit['activity_log_types_disabled_values'];
  $values = array_filter($edit['activity_log_types']);
  $delete = array();
  $add = array();
  foreach ($all as $type) {
    // Previously disabled, now enabled; delete record of it being disabled
    if (in_array($type, $disabled) && in_array($type, $values)) {
      $delete[] = $type;
    }
    // Previously enabled, now disabled; add record of it being disabled
    elseif (!in_array($type, $disabled) && !in_array($type, $values)) {
      $add[] = $type;
    }
  }
  if (!empty($delete)) {
    db_query("DELETE FROM {activity_log_disabled_types} WHERE pid IN (". db_placeholders($delete) .")", $delete);
  }
  if (!empty($add)) {
    $subquery = array();
    $args = array();
    foreach ($add as $type) {
      $subquery[] = "(%d, %d)";
      $args[] = $account->uid;
      $args[] = $type;
    }
    db_query("INSERT INTO {activity_log_disabled_types} (uid, pid) VALUES". implode(',', $subquery), $args);
  }
}

Actions include Unblocking the New User and changing the User Name.

Proposed resolution

None yet.

Remaining tasks

Identify source of error warnings

User interface changes

None yet.

API changes

None yet.

Comments

icecreamyou’s picture

Status: Active » Postponed (maintainer needs more info)

The error indicates that the problem is that $edit['activity_log_types_all_values'] and $edit['activity_log_types'] are not arrays. However I don't see any way they wouldn't be arrays unless Commons itself is alerting the form. Try installing the Devel module and adding dsm($edit); at the top of the _activity_log_user_form_submit() function and see if you can see what's happening.

The good news is that the module will behave as expected regardless of these warnings.

Cyberflyer’s picture

OK, thanks. Since I am the only guy seeing the warnings as Admin, I'm not overly concerned. The data is getting stored.

Got Devel to work and ran an edit of an existing user.

Got this:

activity_log_types (Array, 2 elements)
     1 (Integer) 1
     2 (Integer) 2
activity_log_types_all_values (Array, 2 elements)
     0 (Integer) 1
     1 (Integer) 2

Same result from the first edit on the new user.

So I will have to go do all of this on my production server.

linkerbox’s picture

I'm also seeing this error in the admin recent log entries.

Andrea C’s picture

The log report of our Commons site contains multiple error like the ones below.
The errors are only in the log. We don't see any warning message on the user interface, so is not easy to understand always which was the task that start the error. If I understand the process is:

  1. User_xxxx receive a notification email sent by Commons after user_yyyy wrote a comment
  2. User_xxxx follow the link and enter in Commons
  3. The first two errors are logged as user anonymous:
  4. Commons require mandatory login, but because the session expire in some days the login is done without the need to enter username and password
  5. The next log entry is "Session open by user_xxxx"
  6. Then other two errors are logged as user_xxxx
t-readyroc’s picture

I'm also seeing this exact pair of errors on Commons 6.x-2.6. The errors show up any time a user edits their profile (password change, profile picture upload, etc). Similar to what was reported above, the changed data is getting stored, but the errors persist (site is still in development, so errors are displaying on-screen).

trevorw’s picture

Will be watching this, having same issue here on Drupal Commons 6.x-2.6 but it's been happening for a number of releases now. Doesn't appear to stop anything from working but really annoying seeing "errors" in the logs when they maybe should be "warnings" or corrected. I've spent time trying to track the issue down but an very new to Drupal/Commons so didn't make it very far.

carrierawks’s picture

Version: 6.x-2.x-dev » 6.x-1.x-dev

This is also happening on one of my installs as well.

gregceni’s picture

Mine too and it shows up for every user on every log in (via LDAP).

greggles’s picture

Status: Postponed (maintainer needs more info) » Active

I've seen it too.

Back to active since Cyberflyer provided more info in #3. If there's more info needed, let me know and I'll try to get it.

icecreamyou’s picture

Status: Active » Fixed

Committed fix to dev

This should at least get rid of the error, if not the root cause; but given that reports say the functionality is otherwise working correctly, this fix should be good enough.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.