diff options
author | Chris Smith <toonarmy@phpbb.com> | 2011-09-20 20:00:21 +0100 |
---|---|---|
committer | Chris Smith <toonarmy@phpbb.com> | 2011-09-20 21:06:52 +0100 |
commit | 934a9da313fd6af6986b5320314a2859a1526a1b (patch) | |
tree | ee0c1ca721d3e0497cc6925d5fc96816808c664a | |
parent | b1df91db806f814d24948db773c27f15a731147e (diff) | |
download | forums-934a9da313fd6af6986b5320314a2859a1526a1b.tar forums-934a9da313fd6af6986b5320314a2859a1526a1b.tar.gz forums-934a9da313fd6af6986b5320314a2859a1526a1b.tar.bz2 forums-934a9da313fd6af6986b5320314a2859a1526a1b.tar.xz forums-934a9da313fd6af6986b5320314a2859a1526a1b.zip |
[feature/remove-db-styles] Remove style.php DB storage.
Removed all use of the DB for serving/caching the theme from style.php,
acp_style no longer stores the theme modified time either.
As a consequence currently all stylesheets will be served through style.php
(with no caching) until imagesets are removed [PHPBB3-10336], then
they can we served as static files by HTTPd.
PHPBB3-9741
-rw-r--r-- | phpBB/includes/acp/acp_styles.php | 7 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 2 | ||||
-rw-r--r-- | phpBB/style.php | 66 |
3 files changed, 6 insertions, 69 deletions
diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index c4c01fbc44..388f340e07 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -1265,7 +1265,7 @@ version = {VERSION} trigger_error($user->lang['NO_' . $l_prefix] . adm_back_link($this->u_action), E_USER_WARNING); } - $var_ary = array('style_id', 'style_name', 'style_copyright', 'template_id', 'template_name', 'template_path', 'template_copyright', 'template_inherits_id', 'bbcode_bitfield', 'theme_id', 'theme_name', 'theme_path', 'theme_copyright', 'theme_mtime'); + $var_ary = array('style_id', 'style_name', 'style_copyright', 'template_id', 'template_name', 'template_path', 'template_copyright', 'template_inherits_id', 'bbcode_bitfield', 'theme_id', 'theme_name', 'theme_path', 'theme_copyright'); foreach ($var_ary as $var) { @@ -2439,11 +2439,6 @@ version = {VERSION} break; case 'theme': - // We are only interested in the theme configuration for now - - $sql_ary += array( - 'theme_mtime' => (int) filemtime("{$phpbb_root_path}styles/$path/theme/stylesheet.css") - ); break; } diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 2fa0f89436..23f3e88be4 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4566,7 +4566,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'T_ICONS_PATH' => "{$web_path}{$config['icons_path']}/", 'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/", 'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/", - 'T_STYLESHEET_LINK' => (!$user->theme['theme_storedb']) ? "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css' : append_sid("{$phpbb_root_path}style.$phpEx", 'id=' . $user->theme['style_id'] . '&lang=' . $user->lang_name), + 'T_STYLESHEET_LINK' => append_sid("{$phpbb_root_path}style.$phpEx", 'id=' . $user->theme['style_id'] . '&lang=' . $user->lang_name), 'T_STYLESHEET_LANG_LINK' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/' . $user->lang_name . '/stylesheet.css', 'T_STYLESHEET_NAME' => $user->theme['theme_name'], diff --git a/phpBB/style.php b/phpBB/style.php index 7f7b71d753..c84713f267 100644 --- a/phpBB/style.php +++ b/phpBB/style.php @@ -112,7 +112,7 @@ if ($id) $user = array('user_id' => ANONYMOUS); } - $sql = 'SELECT s.style_id, c.theme_id, c.theme_data, c.theme_path, c.theme_name, c.theme_mtime, t.template_path + $sql = 'SELECT s.style_id, c.theme_id, c.theme_path, c.theme_name, t.template_path FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c WHERE s.style_id = ' . $id . ' AND t.template_id = s.template_id @@ -145,70 +145,12 @@ if ($id) // Expire time of seven days if not recached $expire_time = 7*86400; - $recache = false; - // Re-cache stylesheet data if necessary - if ($recompile || empty($theme['theme_data'])) - { - $recache = (empty($theme['theme_data'])) ? true : false; - $update_time = time(); - - // We test for stylesheet.css because it is faster and most likely the only file changed on common themes - if (!$recache && $theme['theme_mtime'] < @filemtime("{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme/stylesheet.css')) - { - $recache = true; - $update_time = @filemtime("{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme/stylesheet.css'); - } - else if (!$recache) - { - $last_change = $theme['theme_mtime']; - $dir = @opendir("{$phpbb_root_path}styles/{$theme['theme_path']}/theme"); - - if ($dir) - { - while (($entry = readdir($dir)) !== false) - { - if (substr(strrchr($entry, '.'), 1) == 'css' && $last_change < @filemtime("{$phpbb_root_path}styles/{$theme['theme_path']}/theme/{$entry}")) - { - $recache = true; - break; - } - } - closedir($dir); - } - } - } - - if ($recache) - { - include_once($phpbb_root_path . 'includes/acp/acp_styles.' . $phpEx); + include_once($phpbb_root_path . 'includes/acp/acp_styles.' . $phpEx); - $theme['theme_data'] = acp_styles::db_theme_data($theme); - $theme['theme_mtime'] = $update_time; - - // Save CSS contents - $sql_ary = array( - 'theme_mtime' => $theme['theme_mtime'], - 'theme_data' => $theme['theme_data'] - ); - - $sql = 'UPDATE ' . STYLES_THEME_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " - WHERE theme_id = {$theme['theme_id']}"; - $db->sql_query($sql); - - $cache->destroy('sql', STYLES_THEME_TABLE); - } - - // Only set the expire time if the theme changed data is older than 30 minutes - to cope with changes from the ACP - if ($recache || $theme['theme_mtime'] > (time() - 1800)) - { - header('Expires: 0'); - } - else - { - header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + $expire_time)); - } + $theme['theme_data'] = acp_styles::db_theme_data($theme); + header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + $expire_time)); header('Content-type: text/css; charset=UTF-8'); // Echo Theme Data |