Commit 6c20d333 authored by Dries's avatar Dries

- Patch #35667 by Crell: bug fix: on ?q=admin/block style.css was imported twice.

parent cade6b2b
......@@ -28,11 +28,14 @@
/**
* Initialize the theme system by loading the theme.
*
* @return
* The name of the currently selected theme.
*/
function init_theme() {
global $user, $custom_theme, $theme_engine, $theme_key;
global $theme, $user, $custom_theme, $theme_engine, $theme_key;
// If $theme is already set, assume the others are set, too, and do nothing
if (isset($theme)) {
return;
}
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
$themes = list_themes();
......@@ -78,8 +81,6 @@ function init_theme() {
call_user_func($theme_engine .'_init', $themes[$theme]);
}
}
return $theme;
}
/**
......@@ -160,9 +161,10 @@ function list_theme_engines($refresh = FALSE) {
function theme() {
global $theme, $theme_engine;
if ($theme === NULL) {
// Initialize the enabled theme.
$theme = init_theme();
// Because theme() is called a lot, calling init_theme() only to have it
// smartly return is a noticeable performance hit. Don't do it.
if (!isset($theme)) {
init_theme();
}
$args = func_get_args();
......@@ -314,11 +316,11 @@ function theme_get_setting($setting_name, $refresh = FALSE) {
*/
function theme_add_style($path = '', $media = 'all') {
static $styles = array();
if ($path) {
if ($path && !isset($styles["$media:$path"])) {
$style = new stdClass();
$style->path = $path;
$style->media = $media;
$styles[] = $style;
$styles["$media:$path"] = $style;
}
return $styles;
}
......
......@@ -154,9 +154,7 @@ function block_admin_save($edit) {
function _block_rehash($order_by = array('weight')) {
global $theme_key;
if (empty($theme_key)) {
init_theme();
}
init_theme();
$result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $theme_key);
while ($old_block = db_fetch_object($result)) {
......
......@@ -154,9 +154,7 @@ function block_admin_save($edit) {
function _block_rehash($order_by = array('weight')) {
global $theme_key;
if (empty($theme_key)) {
init_theme();
}
init_theme();
$result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $theme_key);
while ($old_block = db_fetch_object($result)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment