Missing Anonymous User

Photo of Greg Harvey
Tue, 2009-11-24 14:12By greg

I've spent the last few days wrestling with an evil bug. I had a content type, called Card, which I could create fine when logged in as any authenticated user of any role. All cool. I should also be able to create this content as anonymous.

Indeed, going to Create Card (node/add/card) was fine. I got the form, filled it in, but then nothing. Page Not Found where the created node was expected. The node simply wasn't created! But there were no warnings or errors. Big fat nada.

Past experience dictated I'd done something stupid in my custom module, which wasn't entirely impossible, as I was trying to redirect somewhere odd after node creation. And so the hoop-jumping began. Check permissions, rebuild permissions, uninstall custom module, re-install, start deleting variables, uninstall a few other modules, and so on and so on. *NOTHING* worked. Eventually I figured it actually wasn't me (shock, horror) and something more sinister was going on.

So by now clumps of my hair are on the office floor and I have no clue what the problem is. Enter our knight in shining armour, Alan Palazzo. Alan saw my desperate tweet and replied thus:

might have something to do with a node access module. Your anonymous user may have been deleted.

So I checked the users table and sure enough, the user ID for Anonymous had somehow changed to 4 (it should be 0). Do not ask me how this happened. I seriously have *no* idea.

But it's a good thing to know. If you start getting weird behaviour for the anonymous user, particularly around posting content, check the users table in Drupal. It could well be your Anonymous user account has gone AWOL. If the "zero" row is missing, or looks wrong compared to another installation, then restore it. It might well save you a lot of pain.

It's on my "to check" list from now on, if I ever experience similar issues again!