Hello - I'm seeing the following warnings when visiting my sites "home" (mysite/home) page:

# warning: Illegal offset type in /home/hollatv/public_html/modules/buddylist/buddylist.module on line 666.
# warning: Illegal offset type in /home/hollatv/public_html/modules/buddylist/buddylist.module on line 667.
# warning: Illegal offset type in /home/hollatv/public_html/modules/buddylist/buddylist.module on line 673.
# warning: Illegal offset type in /home/hollatv/public_html/modules/buddylist/buddylist.module on line 674.
# warning: Illegal offset type in /home/hollatv/public_html/modules/buddylist/buddylist.module on line 675.
# warning: Illegal offset type in /home/hollatv/public_html/modules/buddylist/buddylist.module on line 677.
# warning: Illegal offset type in /home/hollatv/public_html/modules/buddylist/buddylist.module on line 679.

There are additional lines in the warning... but they are repeats of some of the lines in the above snippet. I'm not sure if this is due to a conflict with some other module or a bug in the buddylist module.

thanks

CommentFileSizeAuthor
#4 buddylist.module.patch655 bytesdomidc

Comments

yelvington’s picture

I can duplicate this problem (currently with 5.x.1.0), but (so far) only when anonymous. When logged in, I don't get the error.

Can an anonymous user have buddies?

If not, shouldn't this function immediately return an empty array, rather than attempting to query the database and build a result set?

yelvington’s picture

A bit of debugging reveals that something -- probably some other module -- is calling buddylist_get_buddies() and passing the $user object, not a $uid, as the first argument. A check for is_object() makes the errors go away:

function buddylist_get_buddies($uid = NULL, $key = 'uid') {
  static $buddies;
  if (!$uid) {
    global $user;
    $uid = $user->uid;
  }
  // watchdog('debug', print_r($uid,1));
  if ((!$uid) || (is_object($uid))) return NULL; // don't even try
  if (!isset($buddies[$key][$uid])) { // ... et cetera

(edited to fix fatfingered paste)

domidc’s picture

Title: warning: Illegal offset type in /home/username/public_html/modules/buddylist/buddylist.module on line 666 » warning: Illegal offset type in buddylist.module on line 666

I have duplicated the error when not logged in. When logged in the error doesnt occur. It is the activity module who is calling buddylist_get_buddies() in my case and it passes indeed the user as an object.
The fix works fine.

domidc’s picture

Status: Active » Needs review
StatusFileSize
new655 bytes

This is my first patch. It's made with tortoise CVS and is based on the solution presented in comment #2.

toemaz’s picture

Version: 5.x-1.1-beta » 5.x-1.x-dev
Status: Needs review » Reviewed & tested by the community

I can reproduce the problem and confirm that the fix works.

matt@antinomia’s picture

@yelvington, I think you're right on. For me, activity.module calls:

<?php
$buddies = buddylist_get_buddies($account);
?>

...instead of using $account_id or $account->uid. Are you other folks using activity.module? If so let's move this to the activity.module queue.

matt@antinomia’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

Changing the status back to active, as the above patches the buddylist api, when the patch should likely be for the activity.module's incorrect use of the api.