warning: Invalid argument supplied for foreach() in Drive\Path\modules\user.module on line 1317.

Comments

chx’s picture

Status: Active » Closed (won't fix)
Fusion_Sushi’s picture

I should have provided more information... I'm not sure that this is the same thing:
When accessing index.php?q=user/1

Error:

warning: Invalid argument supplied for foreach() in Drive\Path\www\modules\user.module on line 1317.

I whish I had more information but that's all.. it even happens with a blank user_profile.tpl.php file... so its got to be related to something else.

Fusion_Sushi’s picture

this is the problem line

foreach module_list as module
if data is module_invoke module, user, view, , account
---------> foreach data as category is items
foreach items as item
item class is module. item class
fields ategory is item

Fusion_Sushi’s picture

ahh actually its the next one

foreach ($items as $item)

in the user.module

Fusion_Sushi’s picture

Think this is the problem:

http://drupal.org/node/45444

Fusion_Sushi’s picture

Title: foreach() » foreach() this problem persists
Version: 4.7.0-beta4 » x.y.z

warning: Invalid argument supplied for foreach() in Drive\Path\modules\user.module on line 1343.

Fusion_Sushi’s picture

Well, I'm not sure if its the same problem, might be diffrent. The error is more specific:

// Picture/avatar:
if (variable_get('user_pictures', 0)) {
$form['picture'] = array('#type' => 'fieldset', '#title' => t('Picture'), '#weight' => 1);
------------> $picture = theme('user_picture', (object)$edit);

Fusion_Sushi’s picture

Title: foreach() this problem persists » foreach() this problem fixed!

I probably broke it but here is how to get rid of the error:

Find these lines and cut them out of the user.module on or about 1370

foreach ($items as $item) {
$item['class'] = "$module-". $item['class'];
$fields[$category][] = $item;
}

dallasgrant@newswire.ws’s picture

Title: foreach() this problem fixed! » foreach()
Version: x.y.z » 4.7.0-beta4

Removing the problem line does not work, it is what will display the needed profile information

dallasgrant@newswire.ws’s picture

Title: foreach() » foreach() ... Invalid argument supplied
Priority: Normal » Critical
Status: Closed (won't fix) » Active

The error is as followed:
warning: Invalid argument supplied for foreach() in /home2/wiredban/public_html/v4/modules/user.module on line 1317.

Line 1317 is:
foreach ($items as $item) {

This problem only happens for me when a user is looking at there own profile ... I don't get it when looking at other people's profiles.

greggles’s picture

Priority: Critical » Normal
Status: Active » Closed (won't fix)

I tried to repeat this bug with a current CVS-HEAD and could not repeat it.

dallasgrant (or anyone else) - if the problem persists for you please provide concrete steps that will consistently make the problem show up.

kbahey’s picture

Assigned: Unassigned » kbahey
Status: Closed (won't fix) » Closed (fixed)

I cannot reproduce this in the current HEAD (checked out in the last half hour).

This line is 1401 in user.module 1.584

Is this because of a contrib module misbehaving and returning data that is not an array?

function user_view($uid = 0) {
  global $user;

  if ($account = user_load(array('uid' => $uid, 'status' => 1))) {
    // Retrieve and merge all profile fields:
    $fields = array();
    foreach (module_list() as $module) {
      if ($data = module_invoke($module, 'user', 'view', '', $account)) {
        foreach ($data as $category => $items) {
          foreach ($items as $item) {
            $item['class'] = "$module-". $item['class'];
            $fields[$category][] = $item;
          }
        }
      }
    }
    drupal_set_title($account->name);
    return theme('user_profile', $account, $fields);
  }
  else {
    drupal_not_found();
  }
}
puregin’s picture

nadas0mus, could you please try out the latest CVS head and see if the error persists.

If so, the issue is likely what kbahey suggests, namely, that one of the contributed modules is not returning user information in the proper format. Could you disable your contributed modules one by one and report if you find one that seems to trigger this problem?

Thanks, Djun

benma’s picture

I had the same problem, and tracked it down to the file.module of the e-commerce module - as soon as I activate it, I get the warning, when I deactivate it it disappears...