Commit 6c20d333 authored by Dries's avatar Dries
Browse files

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

parent cade6b2b
...@@ -28,11 +28,14 @@ ...@@ -28,11 +28,14 @@
/** /**
* Initialize the theme system by loading the theme. * Initialize the theme system by loading the theme.
* *
* @return
* The name of the currently selected theme.
*/ */
function init_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); drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
$themes = list_themes(); $themes = list_themes();
...@@ -78,8 +81,6 @@ function init_theme() { ...@@ -78,8 +81,6 @@ function init_theme() {
call_user_func($theme_engine .'_init', $themes[$theme]); call_user_func($theme_engine .'_init', $themes[$theme]);
} }
} }
return $theme;
} }
/** /**
...@@ -160,9 +161,10 @@ function list_theme_engines($refresh = FALSE) { ...@@ -160,9 +161,10 @@ function list_theme_engines($refresh = FALSE) {
function theme() { function theme() {
global $theme, $theme_engine; global $theme, $theme_engine;
if ($theme === NULL) { // Because theme() is called a lot, calling init_theme() only to have it
// Initialize the enabled theme. // smartly return is a noticeable performance hit. Don't do it.
$theme = init_theme(); if (!isset($theme)) {
init_theme();
} }
$args = func_get_args(); $args = func_get_args();
...@@ -314,11 +316,11 @@ function theme_get_setting($setting_name, $refresh = FALSE) { ...@@ -314,11 +316,11 @@ function theme_get_setting($setting_name, $refresh = FALSE) {
*/ */
function theme_add_style($path = '', $media = 'all') { function theme_add_style($path = '', $media = 'all') {
static $styles = array(); static $styles = array();
if ($path) { if ($path && !isset($styles["$media:$path"])) {
$style = new stdClass(); $style = new stdClass();
$style->path = $path; $style->path = $path;
$style->media = $media; $style->media = $media;
$styles[] = $style; $styles["$media:$path"] = $style;
} }
return $styles; return $styles;
} }
......
...@@ -154,9 +154,7 @@ function block_admin_save($edit) { ...@@ -154,9 +154,7 @@ function block_admin_save($edit) {
function _block_rehash($order_by = array('weight')) { function _block_rehash($order_by = array('weight')) {
global $theme_key; global $theme_key;
if (empty($theme_key)) { init_theme();
init_theme();
}
$result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $theme_key); $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $theme_key);
while ($old_block = db_fetch_object($result)) { while ($old_block = db_fetch_object($result)) {
......
...@@ -154,9 +154,7 @@ function block_admin_save($edit) { ...@@ -154,9 +154,7 @@ function block_admin_save($edit) {
function _block_rehash($order_by = array('weight')) { function _block_rehash($order_by = array('weight')) {
global $theme_key; global $theme_key;
if (empty($theme_key)) { init_theme();
init_theme();
}
$result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $theme_key); $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $theme_key);
while ($old_block = db_fetch_object($result)) { while ($old_block = db_fetch_object($result)) {
......
Supports Markdown
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