Skip to content

Commit 1fcf745

Browse files
boesboFrancesco Boesfballiano
authored
Added filemtime to merged JS/CSS hash calculation algorithm (#4004)
Co-authored-by: Francesco Boes <[email protected]> Co-authored-by: Fabrizio Balliano <[email protected]>
1 parent 1f32c70 commit 1fcf745

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

app/code/core/Mage/Core/Model/Design/Package.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,15 @@ public static function getPackageByUserAgent(array $rules, $regexpsConfigPath =
684684
*/
685685
public function getMergedJsUrl($files)
686686
{
687-
$targetFilename = md5(implode(',', $files)) . '.js';
687+
$newestTimestamp = 0;
688+
foreach ($files as $file) {
689+
$filemtime = filemtime($file);
690+
if ($filemtime > $newestTimestamp) {
691+
$newestTimestamp = $filemtime;
692+
}
693+
}
694+
695+
$targetFilename = md5(implode(',', $files) . "|{$newestTimestamp}") . '.js';
688696
$targetDir = $this->_initMergerDir('js');
689697
if (!$targetDir) {
690698
return '';
@@ -720,7 +728,15 @@ public function getMergedCssUrl($files)
720728
}
721729

722730
// merge into target file
723-
$targetFilename = md5(implode(',', $files) . "|{$hostname}|{$port}") . '.css';
731+
$newestTimestamp = 0;
732+
foreach ($files as $file) {
733+
$filemtime = filemtime($file);
734+
if ($filemtime > $newestTimestamp) {
735+
$newestTimestamp = $filemtime;
736+
}
737+
}
738+
739+
$targetFilename = md5(implode(',', $files) . "|{$hostname}|{$port}|{$newestTimestamp}") . '.css';
724740
$mergeFilesResult = $this->_mergeFiles(
725741
$files,
726742
$targetDir . DS . $targetFilename,

0 commit comments

Comments
 (0)