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
Comment #1
icecreamyou commentedThe 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 addingdsm($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.
Comment #3
Cyberflyer commentedOK, 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:
Same result from the first edit on the new user.
So I will have to go do all of this on my production server.
Comment #4
linkerbox commentedI'm also seeing this error in the admin recent log entries.
Comment #5
Andrea C commentedThe 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:
Comment #6
t-readyroc commentedI'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).
Comment #7
trevorw commentedWill 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.
Comment #8
carrierawks commentedThis is also happening on one of my installs as well.
Comment #9
gregceni commentedMine too and it shows up for every user on every log in (via LDAP).
Comment #10
gregglesI'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.
Comment #11
icecreamyou commentedCommitted 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.