Browse Source

optimization: get rid of one more sql query related to installed themes

pull/40/head
czaks 9 years ago
parent
commit
71ef3430fc
  1. 19
      inc/functions.php

19
inc/functions.php

@ -352,9 +352,22 @@ function rebuildThemes($action, $boardname = false) {
$_board = $board;
// List themes
if ($themes = Cache::get("themes")) {
// OK, we already have themes loaded
}
else {
$query = query("SELECT `theme` FROM ``theme_settings`` WHERE `name` IS NULL AND `value` IS NULL") or error(db_error());
$themes = array();
while ($theme = $query->fetch(PDO::FETCH_ASSOC)) {
$themes[] = $theme;
}
Cache::set("themes", $themes);
}
foreach ($themes as $theme) {
// Restore them
$config = $_config;
$board = $_board;
@ -415,6 +428,10 @@ function rebuildTheme($theme, $action, $board = false) {
function themeSettings($theme) {
if ($settings = Cache::get("theme_settings_".$theme)) {
return $settings;
}
$query = prepare("SELECT `name`, `value` FROM ``theme_settings`` WHERE `theme` = :theme AND `name` IS NOT NULL");
$query->bindValue(':theme', $theme);
$query->execute() or error(db_error($query));
@ -424,6 +441,8 @@ function themeSettings($theme) {
$settings[$s['name']] = $s['value'];
}
Cache::set("theme_settings_".$theme, $settings);
return $settings;
}

Loading…
Cancel
Save