aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2007-05-07 15:57:30 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2007-05-07 15:57:30 +0000
commitb7939ba801bd5c4970ade966aa6b423be79f9ef9 (patch)
tree6660efffa9555015d08acb4172bb033a404e6786
parent1ad49ecb91fb7cd7342eca4f0ee82d8b3f8b6ad1 (diff)
downloadforums-b7939ba801bd5c4970ade966aa6b423be79f9ef9.tar
forums-b7939ba801bd5c4970ade966aa6b423be79f9ef9.tar.gz
forums-b7939ba801bd5c4970ade966aa6b423be79f9ef9.tar.bz2
forums-b7939ba801bd5c4970ade966aa6b423be79f9ef9.tar.xz
forums-b7939ba801bd5c4970ade966aa6b423be79f9ef9.zip
implement change style check suggested by code reader.
git-svn-id: file:///svn/phpbb/trunk@7500 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r--phpBB/style.php54
1 files changed, 40 insertions, 14 deletions
diff --git a/phpBB/style.php b/phpBB/style.php
index 150261aba6..f224df9f30 100644
--- a/phpBB/style.php
+++ b/phpBB/style.php
@@ -115,26 +115,52 @@ if ($id && $sid)
}
// Re-cache stylesheet data if necessary
- if ($config['load_tplcompile'] && $theme['theme_mtime'] < @filemtime("{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme/stylesheet.css'))
+ if ($config['load_tplcompile'])
{
- include_once($phpbb_root_path . 'includes/acp/acp_styles.' . $phpEx);
+ $recache = false;
+ $update_time = time();
- $theme['theme_data'] = acp_styles::db_theme_data($theme);
- $theme['theme_mtime'] = @filemtime("{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme/stylesheet.css');
+ // We test for stylesheet.css because it is faster and most likely the only file changed on common themes
+ if ($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
+ {
+ $last_change = $theme['theme_mtime'];
- // Save CSS contents
- $sql_ary = array(
- 'theme_mtime' => $theme['theme_mtime'],
- 'theme_data' => $theme['theme_data']
- );
+ foreach (glob("{$phpbb_root_path}styles/{$theme['theme_path']}/theme/*.css", GLOB_NOSORT) as $file)
+ {
+ if ($last_change < @filemtime($file))
+ {
+ $recache = true;
+ break;
+ }
+ }
+ }
- $sql = 'UPDATE ' . STYLES_THEME_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
- WHERE theme_id = $id";
- $db->sql_query($sql);
+ 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']
+ );
- $cache->destroy('sql', STYLES_THEME_TABLE);
+ $sql = 'UPDATE ' . STYLES_THEME_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
+ WHERE theme_id = $id";
+ $db->sql_query($sql);
- header('Expires: 0');
+ $cache->destroy('sql', STYLES_THEME_TABLE);
+
+ header('Expires: 0');
+ }
}
else
{