I had two D7 websites. I copied the user table from one site and replaced the user table in the second site. On the second site I get the following errors on all pages. Besides the bigger question of what's causing this, I have a second question. Can I ignore this for now and continue developing my site?

Notice: Undefined index: 29 in user_node_load() (line 3501 of C:\xampp\htdocs\drupal\modules\user\user.module).
Notice: Trying to get property of non-object in user_node_load() (line 3501 of C:\xampp\htdocs\drupal\modules\user\user.module).
Notice: Undefined index: 29 in user_node_load() (line 3502 of C:\xampp\htdocs\drupal\modules\user\user.module).
Notice: Trying to get property of non-object in user_node_load() (line 3502 of C:\xampp\htdocs\drupal\modules\user\user.module).
Notice: Undefined index: 29 in user_node_load() (line 3503 of C:\xampp\htdocs\drupal\modules\user\user.module).
Notice: Trying to get property of non-object in user_node_load() (line 3503 of C:\xampp\htdocs\drupal\modules\user\user.module).

Comments

bryancasler’s picture

Lines 3501, 3502 and 3503 are the contents of this foreach loop.

  // Add these values back into the node objects.
  foreach ($uids as $nid => $uid) {
    $nodes[$nid]->name = $user_fields[$uid]->name;
    $nodes[$nid]->picture = $user_fields[$uid]->picture;
    $nodes[$nid]->data = $user_fields[$uid]->data;
  }
bryancasler’s picture

To resolve this I created an user account. Then in the DB I changed that accounts UID to 29. I then went back to the website and deleted the account. Not perfect, but the error seems to have gone away. Someone in the Drupal IRC chatroom suggested that this was a similar error as http://drupal.org/node/826640#comment-3790638

droplet’s picture

Category: bug » support

it pass $nodes object which contains diff UID than your other site user table

bfroehle’s picture

Status: Active » Fixed

It sounds like it is fixed. The node table records the user id of the authors. When you overwrote the users table, you had nodes which no longer corresponded to valid authors.

It is possible that other tables which involve user id's are also slightly corrupted, in particular the users_roles table. Directly editing the SQL tables without knowing what you are doing is, in general, a bad idea.

bryancasler’s picture

Redid my table migration, but before I did I deleted all the roles and users on the site I was migrating the user table to. This resulted in me having no problems.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

anithakr19’s picture

Thank you so much for sharing this. It was really helpful for me to solve the issue when I encountered it! Thanks a bunch!

mile23’s picture

Version: 7.0 » 10.0.x-dev
Issue summary: View changes
darrellduane’s picture

I temporarily added this code into the user.module file so that I could see which nodes were causing the problem and quickly edit them to have a new user assigned to them that has data in the user table. It seems that when I deleted some users the nodes that were owned by them didn't get updated.

// Add these values back into the node objects.
  foreach ($uids as $nid => $uid) {
+    if(!isset($user_fields[$uid]->name))
+   { $type = db_query("SELECT type from {node} WHERE nid = " . $nid)->fetchField();
+      $title  = db_query("SELECT title from {node} WHERE nid = " . $nid)->fetchField();
+      drupal_set_message(l('check ' . $title ,'/node/' . $nid) . ' type: ' . $type );
+      }else{
    $nodes[$nid]->name = $user_fields[$uid]->name;
    $nodes[$nid]->picture = $user_fields[$uid]->picture;
    $nodes[$nid]->data = $user_fields[$uid]->data;
+    }