Fatal error w/ file_directory_path when db connection fails

webchick - June 13, 2007 - 06:12
Project:Drupal
Version:6.x-dev
Component:base system
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed
Description

If you edit your settings.php file to put in invalid information (like what would happen if you moved your install to a different host, or if the database was temporarily unavailable), where you would normally get a nice maintenance page that says "Unable to connect blah blah" you instead get:

Fatal error: Call to undefined function file_directory_path() in /Applications/MAMP/htdocs/head/includes/common.inc on line 1769

#1

webchick - June 13, 2007 - 07:07

Btw, looks like this was introduced in the JS aggregation patch.

#2

xqus - July 4, 2007 - 16:03
Status:active» needs review

Well, here is a simple fix.
Just added the inclusion of includes/file.inc in the drupal_maintenance_theme() function.

A maybe better fix would be to change the drupal_get_js() function to take an argument to disable the JS preprocessing when the database is not available.

AttachmentSize
151394.patch 773 bytes

#3

xqus - July 4, 2007 - 20:04

Here is a different approach. It adds some more checks to the drupal_get_js() function.

AttachmentSize
151394-2.patch 1.03 KB

#4

RobRoy - August 30, 2007 - 06:56

Verified that both patches fix the problem. Just depends on which one is more elegant probably as I think they'll both perform the same. I'm slightly more a fan of #3.

This is a re-roll of patch #2 with trailing spaces removed.

AttachmentSize
file_directory_path_1.patch 710 bytes

#5

RobRoy - August 30, 2007 - 06:57
Status:needs review» reviewed & tested by the community

Here is a re-roll of #3 which I slightly prefer. This abides by coding standards and includes a comment to boot. Gabor, both these patches work, guess it's just up to you which you prefer.

AttachmentSize
file_directory_path_2.patch 1.1 KB

#6

Gábor Hojtsy - August 30, 2007 - 15:48
Status:reviewed & tested by the community» fixed

OK, committed #4, as I think we are better off with including what we need then having special cases for all functions we might not have. The maintenance theme could be any complex. Thanks.

#7

Anonymous - September 13, 2007 - 16:21
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.