diff --git a/application/themehandler.class.inc.php b/application/themehandler.class.inc.php index 43c5053ce6..589f73e61a 100644 --- a/application/themehandler.class.inc.php +++ b/application/themehandler.class.inc.php @@ -109,7 +109,7 @@ class ThemeHandler SetupUtils::builddir($sDefaultThemeDirPath); } - static::CompileTheme($sThemeId, $aDefaultTheme['parameters']); + static::CompileTheme($sThemeId, false, $aDefaultTheme['parameters']); } // Return absolute url to theme compiled css @@ -122,13 +122,14 @@ class ThemeHandler * 2) The produced CSS file exists and its signature is equal to the expected signature (imports, stylesheets, variables) * * @param string $sThemeId + * @param bool $bSetup : indicated whether compilation is performed in setup context (true) or when loading a page/theme (false) * @param array|null $aThemeParameters Parameters (variables, imports, stylesheets) for the theme, if not passed, will be retrieved from compiled DM * @param array|null $aImportsPaths Paths where imports can be found. Must end with '/' * @param string|null $sWorkingPath Path of the folder used during compilation. Must end with a '/' * * @throws \CoreException */ - public static function CompileTheme($sThemeId, $aThemeParameters = null, $aImportsPaths = null, $sWorkingPath = null) + public static function CompileTheme($sThemeId, $bSetup=false, $aThemeParameters = null, $aImportsPaths = null, $sWorkingPath = null) { // Default working path if($sWorkingPath === null) @@ -188,7 +189,7 @@ class ThemeHandler $iFilemetime = @filemtime($sThemeCssPath); $bFileExists = file_exists($sThemeCssPath); $bVarSignatureChanged=false; - if ($bFileExists) + if ($bFileExists && $bSetup) { $sPrecompiledSignature = static::GetSignature($sThemeCssPath); //check variable signature has changed which is independant from any file modification @@ -199,11 +200,16 @@ class ThemeHandler } } - if (!$bFileExists || $bVarSignatureChanged || (is_writable($sThemeFolderPath) && ($iFilemetime < $iStyleLastModified))) { // Dates don't match. Second chance: check if the already compiled stylesheet exists and is consistent based on its signature $sActualSignature = static::ComputeSignature($aThemeParameters, $aImportsPaths); + + if ($bFileExists && !$bSetup) + { + $sPrecompiledSignature = static::GetSignature($sThemeCssPath); + } + if (!empty($sPrecompiledSignature) && $sActualSignature == $sPrecompiledSignature) { touch($sThemeCssPath); // Stylesheet is up to date, mark it as more recent to speedup next time