[development] override theme_maintenance_page

Dave Cohen drupal at dave-cohen.com
Thu Feb 7 00:22:12 UTC 2008

I have a client who's concerned with the content and appearance of pages when 
Drupal is unable to connect to the database.  I agree with their concerns.  
Take for example, the "unable to select database" page.  This shows the 
database host, database name, and database username used by the site.  It 
also shows the Drupal logo instead of the customer's logo.  None of these are 
things that the public should see, even in the case of a fatal error such as 
not connecting to the database.  (Although I recognize these messages are 
appropriate when a user is an administrator installing Drupal or 
troubleshooting, so I don't suggest changing them by default.)

On Drupal.org, there are variety of posts about how to override 
theme_maintenance_page().  The clean approaches do not work when the database 
cannot be reached (because the site's default theme is unknown, you can't 
override theme_maintenance_page the normal way).

I'm thinking of following the example used by custom_url_rewrite.  For those 
who don't know, the custom_url_rewrite() function can be defined in 
settings.php and if found, path.inc will make use of it.  In my case, 
theme.inc's theme_maintenance_page would have code like:

if (function_exists('custom_maintenance_page')) {
  $output = custom_maintenance_page($content, $messages, $partial);
else {
  // Current theme_maintenance_page goes here...
return $output;

My questions for this list are: is this a reasonable approach and would a 
patch to this effect make it into core?



More information about the development mailing list