logo
Published on IntelliWeb.Tools (http://www.intelliwebtools.com)

Drupal - The all Important User Zero

A while back, I came across a "duplicate entry" problem that resulted
from a missing row in my drupal table 'users'.

It turns out that the users table is not the only one that requires
information on "user 0" (aka "anonymous"). This can be caused by
a bug (fixed in CVS) in user deletion. When an admin deletes a user,
accidentally goes back to the confirmation screen and confirms
deletion again, uid 0 is gone. The same happens when two admins
try to delete a user at the same time.

This week I came across another problem in which anonymous
users get a "you are not authorized ..." message when trying to
view any sort of content.

If you find yourself having trouble accessing content or using your
site as an anonymous user, or seeing N/A appearing in the place
of articles you can safely run the following queries against your
Drupal DB (4.6/4.7):


INSERT INTO users (uid, name, mail) VALUES ('0', '', '');
INSERT INTO users_roles (uid, rid) VALUES (0, 1);
INSERT INTO node_access VALUES (0, 0, 'all', 1, 0, 0);



If any of the queries above returns a "duplicate entry" error, that
means a row already exists, and that table is already OK.

This will/should fix the types of problems I mentioned above.

 



 


Source URL:
http://www.intelliwebtools.com/node/1855