Community & Support

Avatar selection error - "The first argument should be an array"

I'm using drupal 5. Recently I've noticed the following error and i cant figure out why I'm getting it.

Anytime a user signs up for the website or when I create one through the admin interface, we get this error:

* warning: array_keys() [function.array-keys]: The first argument should be an array in /var/www/MYSITE/modules/avatar_selection/avatar_selection.module on line 365.

* warning: in_array() [function.in-array]: Wrong datatype for second argument in /var/www/MYSITE/modules/avatar_selection/avatar_selection.module on line 365.

Here is the code from line 352 to 371. Could somebody please help me fix this error from popping up? Thanks!!

/**
* Select a random avatar picture for a certain user.
*
* @param $user
*   User object.
* @return
*   Return the path to the image to be shown as avatar.
*/
function avatar_selection_get_random_image($user) {
  $avatars = _avatar_selection_image_list($user);
  if ($avatars['total'] > 0) {
    $avatar = array_rand($avatars['avatars'], 1);
    if ($avatar) {
      $path = file_create_path('avatar_selection');
      $avatar = $path .'/'. $avatar;
      return $avatar;
    }
  }
  return ' ';
}