I have noticed a bug with using the default favicon setting.

My Drupal install has a besopke custom frontend template and uses the rootcandy theme as the admin theme.

When I goto my custom theme settings 'admin/build/themes/settings/mytheme' as the admin template is set to rootcandy it loads the rootcandy settings so the following code checks the rootcandy theme for a favicon in 'theme_get_settings'

<?php

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';
        }
}

?>

$theme_object will always be the current theme in use and not the one selected to configure from within the admin section. So instead of checking for 'sites/all/themes/mytheme/favicon.ico' or whatever the selected theme is it will check for 'sites/all/themes/rootcandy.ico'.

For the time being I have added the following hack:

<?php
/**
 * Retrieve a setting for the current theme.
 * This function is designed for use from within themes & engines
 * to determine theme settings made in the admin interface.
 *
 * Caches values for speed (use $refresh = TRUE to refresh cache)
 *
 * @param $setting_name
 *  The name of the setting to be retrieved.
 *
 * @param $refresh
 *  Whether to reload the cache of settings.
 *
 * @return
 *   The value of the requested setting, NULL if the setting does not exist.
 */
function theme_get_setting($setting_name, $refresh = FALSE) {
  global $theme_key;
  static $settings;
  
  $currentTheme = preg_match('%admin/build/themes/settings/.*%',$_GET['q'], $matches) ? $matches[1] : $theme_key ;

  if (empty($settings) || $refresh) {
    $settings = theme_get_settings($currentTheme);

    $themes = list_themes();
    $theme_object = $themes[$currentTheme];

    if ($settings['mission'] == '') {
      $settings['mission'] = variable_get('site_mission', '');
    }

    if (!$settings['toggle_mission']) {
      $settings['mission'] = '';
    }

    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;
}
?>

Unfortunatley I am a little short on time to come up with a better fix but if I'm not beaten to it I'll take a look when I am free.

Comments

dvessel’s picture

Status: Active » Closed (won't fix)

I don't understand the issue. If the problem is still there, feel free to re-open and clarify by outlining the exact steps to reproduce the problem.