mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[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
This commit is contained in:
parent
b1df91db80
commit
934a9da313
3 changed files with 6 additions and 69 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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'],
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
$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));
|
||||
}
|
||||
|
||||
header('Content-type: text/css; charset=UTF-8');
|
||||
|
||||
// Echo Theme Data
|
||||
|
|
Loading…
Add table
Reference in a new issue