Drupal v6.2 here.
When I was new to Drupal (a month or more ago) someone told me that it would probably be safe to just go ahead and delete node 0 since my admin node is "1" anyway. Well, I did and then 15 minutes later, another poster says that I should not have deleted node 0. So I was scratching my head but soon put it behind me.
Fast forward a little more than a month later and I was doing some configuration today in...
Home » Administer » Site building » Blocks
at the URL.../blogs/admin/build/block/configure/profile/0
and saw the following message on a pink background at the top...
"warning: Invalid argument supplied for foreach() in /home/iloveblogging/public_html/blogs/includes/form.inc on line 1181."
I was just wondering, how do I recreate node 0 so I can correct this error -or- is there some Drupal repair utility that will allow me to recreate it?. Any help would be greatly appreciated as I'm not sure what to do now.
- Steve
Comments
=-=
I assume you mean UID 0 and not node 0
removing UID 0 means you removed the anon user
install a fresh drupal, inspect the user table to see how this UID is formed then recreate on your production DB.
Sorry, yes, UID 0.
Sorry, yes, UID 0.
I've done a great deal of customizing over the last month so even if I do a DB restore after installing a fresh copy of Drupal, it's going to be nearly impossible to get all of my many changes and customizations back. Is it possible to do this another way or do I really even need UID 0 at all?. Also, I'm not a PHP programmer and know only a small amount about MySQL server commands so I'm hoping there is a quick and easy way around this...maybe insert some MySQL code into phpMyAdmin?.
Thanks so much for your reply and help.
- Steve
From the top of my head,
From the top of my head, assuming you are not using table prefixes,
insert into users (uid) values (0);should do it for you.If you are using prefixes, you need to change table name accordingly.
HillsWeb.com
Hills Web
I tried the code you
I tried the code you provided but I still got the error message and even if I install a fresh copy of Drupal and then restore the database, the restored database is still going to reflect the same missing UID 0 isn't it?.
As far as prefixes are concerned, my DB name looks like this: "iloveblogging_drpl1". Is this a prefix and what should I do now?. I'm not even sure how to undo the code I just added.
- Steve
Yes you're right about database restoration and missing user #0
So let's stick with the correct way of doing it;)
In your drupal site configuration file there is a setting for table prefix. You can also run
show tables like "%users"in phpmyadmin and find your users table name.After you find the correct name, you can modify my query and run it.
Don't worry about "undoing" my code yet ;)
HillsWeb.com
Hills Web
Thanks for sticking it out
Thanks for sticking it out with me on this. Hopefully, I'll get to the bottom of it before it's all said and done with your help :).
Ok, now when you say "drupal site configuration file" are you referring to...
A) A file within one of Drupal's folders and if so, which one and what is the exact name of the file?
B) An option within the Drupal admin panel?
C) An option within Drupal's database via phpMyAdmin?
Also, when you say "show tables like "%users"", I'm not quite sure which part of phpMyAdmin I am supposed to copy/paste this to.
As an aside, I clicked on the "SQL" tab within phpMyAdmin and that is where I pasted your code and it said that the table row had been created but when I checked the UID section, I could not find "0" but instead, it started at "1" (ie; BROWSE>USERS>UID>1 admin).
- Steve
never mind the config file
In your phpmyadmin, you can see all the tables and their content.
If it said the row was inserted, it probably was. You can find the users table in phpmyadmin and see that the user 0 is there. The problem is elsewere then.
HillsWeb.com
Hills Web
See, here's the thing (just
See, here's the thing (just to give you a little history here and to be more specific)...
When I first started using Drupal about a month ago, I did a MySQL database check via CPanel to see if there were any tables that needed to be repaired before I did a DB backup via phpMyAdmin.
I did see a number of errors and so I ran a repair.
All errors except one were repaired but no matter how many times I ran the repair, there was one table that kept giving me an error and it said something like "auto-increment error user 0" (or something like that).
So, naturally, not wanting to do a DB backup with errors in it, I posted about it on the forum here and was told that I could probably just safely delete it (which I did). Then, about 15 minutes later, another person posts telling me that I should not have done that.
So there's a bit of history on how all of this started. Now, my install of Drupal runs good, looks good, backs up and restores good and is fully customized and I am very proud of it and all of this with no "UID 0" so I'm really wondering if I even *need* UID 0 in the first place but since I am told that I DO, I would really like to recreate it if at all possible.
Thanks for listening and for any further help I can get with this. I very much appreciate it.
- Steve
Most likely your current
Most likely your current problem has nothing to do with user 0
HillsWeb.com
Hills Web
PHPMyAdmin errors out
I have the same problem (no UID 0) except I never knowingly removed mine. When I try your SQL code in PHPMyAdmin, it returns a "File too large" error. I've also tried doing an insert to try to get it back in, and PHPMyAdmin doesn't like that either (headers already sent - about half a screen worth).
Is there another way, perhaps with PHP code to insert UID 0?? I'm at a loss here. Drupal version 5.10
Thanks in advance for any ideas.
Skip
It's apparently a PHPMyAdmin
It's apparently a PHPMyAdmin problem. I had forgotten about using the CLI for MySQL. So I SSH'd in and did an insert using MySQL and it worked fine.
I now have my UID 0 back.
Appears to be a Drupal Profile bug.
Just tried the link and ran into the exact same error. I guessing this error goes away after you save the block configuration?
Changing the line 155 in profile.module to this fixes the problem for me:
to
The problem is that the
variable_getfunction should return an array, and when this returns NULL, it causes the error in the checkbox theming function. It is fixed in head.Alan Davison
www.caignwebs.com.au
Alan Davison
Interesting
Interesting observation/assessment. Very helpful indeed. Which folder/file contains the code you posted above?. I would be very interested in trying your example.
Thanks, Steve
=-=
as it says, the profile.module which is in the modules folder
Oh ok, I was thinking
Oh ok, I was thinking "profile module" being just a generic term to describe some module within Drupal. I didn't know that it was the actual name of the file nor was it stated by the previous poster which folder it was located in (still feeling my way around this). Thanks for filling me in.
Finally, this still does not resolve the issue of restoring of UID 0 so really, I get rid of the message but I am still missing UID 0. Does anyone here at all know how to restore it?. Perhaps install Drupal on another machine and them copy UID 0 and "paste" it into the original Drupal installation?.
I'm stumped here...
- Steve
=-=
This is what I suggested in my first comment. http://drupal.org/node/262669#comment-856989
Yes, I know you did but it's
Yes, I know you did but it's just that I'm not exactly a genius when it comes to programming/tweaking PHP/MySQL so once I create the fresh install, what am I supposed to do in order to get UID 0 back since (as I stated earlier) once I do a DB restore, it's just going to take me right back to the missing UID 0 issue. In other words, my DB backup does not have the UID 0...it's missing...gone...kaput.
- Steve
=-=
I'm simply trying to guide you to inspect a fresh DB with the UID = 0 and then recreate what you see on the fresh setup in the user table on your own. Noone stated to do a DB restore.
That said, Have you even checked your user table to insure that UID 0 is indeed missing ? because running the update given by Hillsweb in http://drupal.org/node/262669#comment-857001 should have recreated UID 0 in your users table in the DB
are you sure you ran that query in phpmyadmin ?
browing the UID 0 row
mode
sort
threshold
created
access
login
& status should also be 0
timezone and data should be checked "null"
Ok, I assumed that I was to
Ok, I assumed that I was to install a fresh copy of Drupal and then upload my DB (which would only re-add the missing UID 0). As a non-PHP geek, I'm not sure how I would recreate UID 0 anyway after installing the fresh copy.
Looking at: phpMyAdmin>_drpl1>Structure>Users>Browse> and then looking at the UID column, I don't see a "0" (it starts at "1" but there is no UID "0"). UID 1 is listed as the "admin".
Hmmm...now that I look at your list again, I don't see any of those things so maybe I'm not even in the right section...
- Steve
Just tried the code you
Just tried the code you provided and it worked...no more error. Thanks :). Now, if I could only recreate the elusive "UID 0" I would be a happy camper.
- Steve
Confim the "UID0" error. I
Confim the "UID0" error. However, with my current install I don't have it. I can't remember if the error showed in a 6.1 install or a 6.2 install. Currently running version 6.2 with virgin data.
@stevenwhite -
Did you by any change upgrade your database from 6.1 to 6.2? Or did you start from 6.2?
It will help track this down.
I used Fantastico to install
I used Fantastico to install Drupal v6.1. Then, I upgraded (manually) to v.6.2 using the file offered at Drupal.org.
On my server, however, I did everything manually (created the DB, installed v6.2, etc).
Let me check and see if I am lacking UID 0 on the server machine (I know I deleted it on my host)...
- Steve
No, I just checked on the
No, I just checked on the server machine and it starts at UID 1 as well but then again, I used the DB backup containing the missing UID 0 to restore Drupal on the server machine just like I did to restore the one on the host.
The DB backup is missing the UID 0 so it looks like no matter what I do (unless I start completely from scratch and lose EVERYTHING) I'm never going to get it back again. Of course, unless there is some way to do an insertion of the missing UID 0 into MySQL.
- Steve
=-=
INSERT INTO users (uid) VALUES ('0');try using the above in phpmyadmin to restore your UID 0
backup your DB before doing so.
Thanks VeryMisunderstood.
Thanks VeryMisunderstood. Just wondering though, do I insert this under the "SQL" tab (in that little box)?. I'm using phpMyAdmin. I see a box that says...
"Run SQL query/queries on database iloveblogging_drpl1"
- Steve
=-=
yes
Something came up but I'll
Something came up but I'll try this shortly. Thanks for your help (all of you). Incidentally, how do you PM other people here?. I have this feature enabled in my own install of Drupal and it works pretty good.
- Steve
=-=
There is no PM module installed on drupal.org and I don't expect there to be. users who don't mind being contacted through Drupal.org use the contact tab on that users profile.
used phpmyadmin
I'm really glad to find this thread!
I had a problem related to: http://drupal.org/node/204411
and I fixed it by using phpmyadmin and edited the row that had the anonymous user in it (the row was still in the table, but during export/import of the database the autoincrement changed the id number from 0 to (3 or 4 or something)... so I just browsed the table in phymyadmin, then edited the row, and changed the number to 0.
Thanks! I love this community!
Cathy Theys
YesTrainingAndEducation.com
Don't forget rid 1 too
Had similar problem along this line.
Don't forget in user_roles table to insert uid 0 and rid 1, also. This ties user 0 to the anonymous role!
Thank you!
Thanks rgammon. That's exactly what my issue was. I had the UID of 0 but not in the user_roles. Cheers H
Thanks!
Same problem was here.
I had created a view of users, and it always showed an empty user line. Which I (dumbly) deleted per "delete" link. Bad Idea, that was the anonymous user.
Then suddenly some nodes were sort of "gone" - thye was visible in views lists, but not accessible any more as node itself.
Thanks to the community here, the commands above repaired it:
I took an old backup .sql file of the database and extracted the followind line:
INSERT INTO `users` VALUES ('0','','','','0','0','0','','','0','0','0','0','0',null,'','','',null,'');
Then I manually changed the uid to 0 (because the autoincrement feature had put it at 142)
then I created an entry in user_role with uid 0 and rid 1;
that was it.
Thank you again, very much.
Christian
Similar problem here:
Similar problem here: #184247: Status Messages not being displayed after registration #7
This might be the reason why
This might be the reason why uid 0 is missing.
#243423: User with uid=0 will change uid when copied/inserted to {users} table with MySQL and MyISAM table, breaks anonymous postings
My Drupal sites:
Added a handbook page
I've added a handbook page to help others who might have this issue: http://drupal.org/node/1029506
thanks
thanks for this info, I mistakenly deleted user with UID 0 and this helped me to return it back!