currently working on a new site - first everything went well - including the user profile pages. Then one fine day I checked the profile pages again - and found this error message:

warning: Invalid argument supplied for foreach() in /www/htdocs/w00856ed/drupal/modules/user/user.module on line 1507.

I looked around and found some forum posts with exactly the same problem - and some with similar problems (other modules) but couldn't find any way out..

I tried to deactivate different modules - but the error stayed the same ever since - and it also stays with new user accounts.

Although one things makes me very curious - and also hopeful that somebode else might have the right idea: the error message won't show if somebode looks at her/his own profile page - so if user #3 looks at user/3 no error - but if user #2 looks at user/3 -> error ..the same thing goes also the other way round...

thank you very much for any suggestions and/or pointers in any direction!

greetz, t..

Comments

Peter Martin’s picture

I'm having the exact same problem. Help anyone?

Etanol’s picture

same here - anyone?

2houseplague’s picture

Ditto.

Seems a handful are struggling with this problem:user.module on line 1507.

tille’s picture

I finally found some post with a very similar problem:
http://drupal.org/node/125902

..which led me to solving my own problem:

The problem seems to be that in line 1507 (in function user_view($uid = 0)) the user.module returns an error if the array $items is empty. I 'debugged' this for now by adding an appropriate if-statement there so that it now checks if the array actually contains anything:

// 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) {

  	if ( is_array($items) ) {

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

      }
    }
  }

I'm actually not realy sure if this is a bug - but now it works..

Just in case I also posted this over at the issues:
http://drupal.org/node/162041

hope it helps for now..?

greetz, t.

___________________________
my pictures: www.bilderbook.org

___________________________

forsythes’s picture

Thank you! Your fix worked well!

manimal’s picture

after trying this, I recieve this error:

Parse error: syntax error, unexpected $end in /var/www/drupal/modules/user/user.module on line 2663

tille’s picture

hi manimal,

strange - seems like there' one "$end" too much on the way - or maybe it's a "}" too much that could cause that..? Hm. What else is there in your line 2663..? ..at least in my (partly 'patched'/'hacked') user module (D.5.2) it looks as if it was the very last line of function user_filter_form_submit.. - ..and i cant really see a reason for an unexpected "$end"...?¿

greetings, t..

___________________________
my pictures: www.bilderbook.org

___________________________