When there is database problem, _db_error_page() is called to show a themed error page. This page is themed according $conf['maintenance_theme'] setting in settings.php or default to 'minnelli'. The site logo can be set. However, it's impossible to set the favicon.

First, logo and favicon are set in theme_get_setting():

function theme_get_setting($setting_name, $refresh = FALSE) {

    ...

    if ($settings['toggle_logo']) {
      if ($settings['default_logo']) {
        $settings['logo'] = base_path() . dirname($theme_object->filename) .'/logo.png';
      }
      elseif ($settings['logo_path']) {
        $settings['logo'] = base_path() . $settings['logo_path'];
      }
    }

    if ($settings['toggle_favicon']) {
      if ($settings['default_favicon']) {
        if (file_exists($favicon = dirname($theme_object->filename) .'/favicon.ico')) {
          $settings['favicon'] = base_path() . $favicon;
        }
        else {
          $settings['favicon'] = base_path() .'misc/favicon.ico';
        }
      }
      elseif ($settings['favicon_path']) {
        $settings['favicon'] = base_path() . $settings['favicon_path'];
      }
      else {
        $settings['toggle_favicon'] = FALSE;
      }
    }
  }

  return isset($settings[$setting_name]) ? $settings[$setting_name] : NULL;
}

So by setting 'toggle_logo' and 'toggle_favicon' to FALSE, we can override these logic and force the setting in settings.php like this (I'm using the 'chameleon' theme):

$conf = array(
  'site_name' => 'My Extra Spiffy Site',
  'maintenance_theme' => 'chameleon',
  'theme_chameleon_settings' => array(
    'toggle_favicon' => FALSE,
    'favicon' => '/sites/www.mysite.com/files/garland_favicon_0.ico',
    'toggle_logo' => FALSE,
    'logo' => '/sites/www.mysite.com/files/garland_logo.png',
  ),  
);

The 'theme_chameleon_settings' only applies when the chameleon theme is used in error mode. Logo works this way. But not favicon because in theme.maintenance.inc there is a test for 'toggle_favicon':

function template_preprocess_maintenance_page(&$variables) {
  // Add favicon
  if (theme_get_setting('toggle_favicon')) {
    drupal_set_html_head('<link rel="shortcut icon" href="'. check_url(theme_get_setting('favicon')) .'" type="image/x-icon" />');
  }

...

Removing the test for 'toggle_favicon' would fix the problem. This should not cause any problem.

There is another way to set logo and favicon by simply saving the files favicon.ico and logo.png in the theme directory. But this is no good for multisite install.

Comments

multiplextor’s picture

Status: Active » Closed (won't fix)

Closed. The reason: expired.