Community

Undefined index: 0 in user_node_load() ...

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

=-=

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?

I have a similar

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).

...

=-=

the questions in http://drupal.org/node/1885428#comment-6925404 still apply

Resolved

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.

nobody click here