Greetings,
I am getting this Error message on only one of my Drupal 7.18 pages.

Error

    Notice: Undefined index: 0 in user_node_load() (line 3586 of /brain/modules/user/user.module).
    Notice: Trying to get property of non-object in user_node_load() (line 3586 of /brain/modules/user/user.module).
    Notice: Undefined index: 0 in user_node_load() (line 3587 of /brain/modules/user/user.module).
    Notice: Trying to get property of non-object in user_node_load() (line 3587 of /brain/modules/user/user.module).
    Notice: Undefined index: 0 in user_node_load() (line 3588 of /brain/modules/user/user.module).
    Notice: Trying to get property of non-object in user_node_load() (line 3588 of /brain/modules/user/user.module).

I look into user.module to reference line # 3586, 3587 and 3588 but am not really great at reading the code and understanding what to do next.

user.module

3571 	/**
3572 * Implements hook_node_load().
3573 */
3574 function user_node_load($nodes, $types) {
3575   // Build an array of all uids for node authors, keyed by nid.
3576   $uids = array();
3577   foreach ($nodes as $nid => $node) {
3578     $uids[$nid] = $node->uid;
3579   }
3580 
3581    // Fetch name, picture, and data for these users.
3582   $user_fields = db_query("SELECT uid, name, picture, data FROM {users} WHERE uid IN (:uids)", array(':uids' => $uids))->fetchAllAssoc('uid');
3583 
3584   // Add these values back into the node objects.
3585   foreach ($uids as $nid => $uid) {
3586     $nodes[$nid]->name = $user_fields[$uid]->name;
3587     $nodes[$nid]->picture = $user_fields[$uid]->picture;
3588     $nodes[$nid]->data = $user_fields[$uid]->data;
3589   }
3590  }

Any tips on troubleshooting this would be greatly appreciated.
Thanks

Comments

VM’s picture

you're getting it on only 1 of your drupal pages. which page? does it have any custom php code? what version of php is in use?

Has the site ever been updated? did you run update.php?

in the user table of the database do you have user 0?

galch24’s picture

I have a similar problem.

PHP 5.3.3-7+squeeze14
Drupal 7.18
views 7.x-3.5

The problem appeared on the output views page. That views display does not contain php code. It is a simple table with fields of the nodes, filter by node type.
Also that problem appeared on the admin/content page.

There is the text of the alarm messages:

Notice: Undefined index: 0 in function user_node_load() (line 3586 in file /modules/user/user.module).
Notice: Trying to get property of non-object in function user_node_load() (line 3586 in file /modules/user/user.module).
Notice: Undefined index: 0 in function user_node_load() (line 3587 in file /modules/user/user.module).
Notice: Trying to get property of non-object in function user_node_load() (line 3587 in file /modules/user/user.module).
Notice: Undefined index: 0 in function user_node_load() (line 3588 in file /modules/user/user.module).
Notice: Trying to get property of non-object in function user_node_load() (line 3588 in file /modules/user/user.module).
Notice: Undefined index: 0 in function user_node_load() (line 3586 in file /modules/user/user.module).
Notice: Trying to get property of non-object in function user_node_load() (line 3586 in file /modules/user/user.module).
Notice: Undefined index: 0 in function user_node_load() (line 3587 in file /modules/user/user.module).
Notice: Trying to get property of non-object in function user_node_load() (line 3587 in file /modules/user/user.module).
Notice: Undefined index: 0 in function user_node_load() (line 3588 in file /modules/user/user.module).
Notice: Trying to get property of non-object in function user_node_load() (line 3588 in file /modules/user/user.module).

...
VM’s picture

GhosThit’s picture

For now this issue has been resolved for me. The node the page was coming up on was a test-node anyway, so I just scrapped the node and created a new one. The error was also coming up on any 'Edit User Profile' page but is not anymore so.. o_O I dunno.

albertomota’s picture

Just for future reference, Drupal seems to need to have a user with ID 0 on the database; I had accidentally removed it and got these error messages.

Once I added the user back again the messages were gone.

Mugé’s picture

Worked like a charm. I had no password for the user, so I deleted it. The long pink Error gives me the creeps with Drupal each and every time.

I recreated a user through admin panel
> People > Add User.
> Went into phpMyAdmin through the host
> Changed the created users ID to 0 (zero)
> Worked

Thank you very much for your help.

YuvalBH’s picture

what a silly bug...why they don't solve it ??

4paws’s picture

This happened when I exported my content to another installation (using the module "Data export import") and viewed the content - the new install was looking for the same user id that created the content on the original site. I added a new user and changed the id to the same number (in my case it was "Notice: Undefined index: 10 in user_node_load..."), and it worked.

esc_two’s picture

so are ya'll saying to log in to my linux server/MySql server, find the user table for the site i'm trying to remove these pesky errors on, and manually ADD an additional user 0? 

VM’s picture

The table should be checked. if the anon user isn't there, it should be.

esc_two’s picture

I think I understand - so will adding a new anonymous user merely through the people/users in config do the trick?

VM’s picture

no since every anon users assumes the same UID of 0. Generating a new user and naming it anon isn't the same thing at all.

esc_two’s picture

unfortunately, i don't have access to login to our linux servers where the tables live

i'll need to work with our database manager for that

are you saying that i/we...

1. login to linux/ubuntu/MySql 

2. access the respective site

3. access the users table

4. take a look - if there is no user 0, thats most likely the problem

Then what? manual add a user 0 to the table, which must be done with cmd line commands

and will it say anonymous in the user table (i doubt it)

VM’s picture

no idea if its 'most lilkey' your  problem. Just know the UID 0 should be in the user table. Suggest reviewing an install without the issue and compare.