Drupal 4.6.4, MySQL 4.1, PHP 5, Apache 2. Followed installation instructions; Drupal is located in \drupal subdirectory of the Apache htdocs directory, base_url set to "http://localhost/drupal", db_url to "mysql://u_drupal:pw_drupal@localhost/drupal". I think the database is set correctly because logging is as the u_drupal user I can query and see content in the 'system' table, and when (following advice of one poster on install page) I tried swapping the u_drupal and pw_drupal in the db_url, I got a DB login error in Drupal. When I go to http://localhost/drupal I initially get the login page. Click on "Create new account" and I get a page with a bunch of warnings -- mostly "warning: array_keys() [function.array-keys]: The first argument should be an array in ...\drupal\includes\menu.inc on line 916.", "wrong parameter count for min() in ...\drupal\includes\menu.inc on line 916", and some about problems creating the header. At the bottom of the page is the Drupal blue bar and logo and "Page not found". I'm assuming the warnings may be related, but are related to constructing surrounding pieces of the page (like menus) but I'm unable to track down what page is missing. If I go back to http://localhost/drupal subsequently I always get the php warnings. I can drop, recreate, and repopulate the drupal database, which gives me the clean login page once more, but always with the same result (warnings and "page not found"). The apache log shows no 404 errors.

Any suggestions on Drupal debugging techniques or how to get to the root of this?

Many thanks!

Comments

BlackSash’s picture

The problem here (extrapolated from your brief mention of header errors) is probably that there's extra whitespace at the end of some of your PHP files.

Having an extra space or newline after the ?> tag in any of the PHP files needed for rendering the page causes the entire system to collapse, bringing on a message statin all sorts of errors in your include files.

the best way to solve this is to simply check the most important files for any extra whitespace after the closing tag and removing it if found.

Since this is a new installation, the culprit is most likely the settings.php file. If not, you'll have to take a look at some of the other files in the modules and includes directories.

Anonymous’s picture

Many thanks for the suggestion -- it seemed like a really good one, especially since I edited some of the files using Windows utilities (notepad or write) and write.exe does do silent cr/lf replacements, which seemed like it may well result in something like this happening.

However, I checked the files and it doesn't look to me like there are any extra whitespace characters after the closing ?> tag. The only files that have been modified since the install were -- as you correctly suspected -- settings.php and the .htaccess file (following a suggestion in another forum thread about putting Drupal in a subdirectory). But I installed emacs and checked both of these files, and verified that they don't have any characters at the end.

Some more detail on the headers issue: the exact warning I'm getting is "warning: Cannot modify header information - headers already sent by (output started at ...\drupal\includes\common.inc:384) in ...\drupal\includes\common.inc on line 99."

The bulk of the warning messages are coming from the line in menu.inc preceded by the comment "Menu items not in the DB get temporary negative IDs" The other warnings suggest that a variable $menu should be an array but isn't. Again, the warnings may or may not have anything to do with the Page not Found.

Many thanks for the reply, and for any other suggestions!

Anonymous’s picture

I found a workaround for the problem -- the issue could be resolved by deleting the menu cache entries from the drupal.cache table. I didn't test whether I could get away with just removing entries for the current user -- I routinely deleted them all (when I discovered I didn't need to truncate the table entirely). This allowed me to access most of the functionality, but still doesn't explain why I was running into this problem quite reliably and reproducibly in vanilla as-installed Drupal 4.6 "out of the box". I finally disabled the menu caching functionality by commenting out the line (in menu.inc, if I recall correctly) that actually caches the value (I don't have the file accessible at the moment to quote the exact line). There were still some other issues going on that may or may not have been related -- setting access permissions for different user roles, for example.

Is anyone familiar enough with the caching scheme or with the "Menu cache prohibiting..." bug (http://drupal.org/node/24034) to know whether this is likely to be the cause, or at least related, and whether the fix is (or will be) rolled into the distribution (since I hate to patch my version locally)?

Dahaniel’s picture

I have the same problem with Drupal 5.1.
Flushing the menu_cache table is a probability but won't fix for a long time. Always when I play around with modules or so, it appears again.
How can I switch off the menu caching?

knugar’s picture

I run into the same problem when I tried to create a clone of a production site on localhost.

After importing the drupal DB to localhost etc I got the cloned drupal site up and running but the default theme from the production site was not used and I got the same type of page not found and array_key errors as DDaniel.

I was happy to find this topic in the forums! After deleting all rows in drupal.cache table most of the errors dissapaired.

I still get

warning: array_merge() [function.array-merge]: Argument #2 is not an array in /var/www/localhost/htdocs/drupal/includes/theme.inc on line 255.

which I will try to resolve.