Recently, a friend of mine contacted me regarding his Drupal website; all website contents were missing and he even could not log into the website and check the situation.
He was in a great hurry and I checked the website shortly. Except the homepage -which looked to be set on /node- every other links were not accessible.
I asked him about any change in code and settings or anything unusual. He replied that he has not changed anything; just the fact that the web server was not fully responsive at the time of problem.
My first though was that he has corrupted the .htaccess file or there is no such file in Drupal installation root at all and asked him to check the file. This situation occurs too many times to people -even me. Those whom are Linux or Mac users and use GUI to copy the files, usually miss that file because it is considered "hidden" in those operating systems. But .htaccess was there, safe and sound.
I checked the /user URL by setting the query string for avoiding the .htaccess and mod_rewrite problems:
Then I checked the database. First emptied all the caches. Problem still persisted. Finally, after a little search in google, I found the problem.
I checked the table menu_router. This is where all the menu entries which are defined by modules in hook_menu are cached for speed up. Every path/menu entry you try to access is looked up in this table first, so if it is missing by any cause, you won't have access to that path.
This tables is cleared and rebuilt every while and then: when you enable a new module, for example.
In that table, I just found 7 menu entires which was definitely wrong.
Now I had found the problem, I needed to fix it. But there was no way for me to log in and make Drupal to regenerate the entries.
There is a variable, menu_rebuild_needed which when is set to true, tells Drupal to rebuild the menu_router from scratch. I checked the variable table and created the variable with serialized 1: i:1; and refreshed a page; nothing happened. I don't know why.
Finally I tried to clear the cache by code. I created a .php file in Drupal installation root and put following lines in it and called the page from browser:
Bingo! Table was rebuilt and site was fixed.
I believe the reason for table menu_router corruption was a server crash. But the interesting fact is this cannot be fixed by a normal Drupal user. I am wondering is it possible to make this situation easier to fix for all kind of users?
Comments
<p>nice, was usefull</p>
Post new comment