Skip to content

Commit

Permalink
Added filemtime to merged JS/CSS hash calculation algorithm (#4004)
Browse files Browse the repository at this point in the history
Co-authored-by: Francesco Boes <francesco@onoratogroup.org>
Co-authored-by: Fabrizio Balliano <fabrizio.balliano@gmail.com>
  • Loading branch information
3 people authored May 29, 2024
1 parent 1f32c70 commit 1fcf745
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions app/code/core/Mage/Core/Model/Design/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,15 @@ public static function getPackageByUserAgent(array $rules, $regexpsConfigPath =
*/
public function getMergedJsUrl($files)
{
$targetFilename = md5(implode(',', $files)) . '.js';
$newestTimestamp = 0;
foreach ($files as $file) {
$filemtime = filemtime($file);
if ($filemtime > $newestTimestamp) {
$newestTimestamp = $filemtime;
}
}

$targetFilename = md5(implode(',', $files) . "|{$newestTimestamp}") . '.js';
$targetDir = $this->_initMergerDir('js');
if (!$targetDir) {
return '';
Expand Down Expand Up @@ -720,7 +728,15 @@ public function getMergedCssUrl($files)
}

// merge into target file
$targetFilename = md5(implode(',', $files) . "|{$hostname}|{$port}") . '.css';
$newestTimestamp = 0;
foreach ($files as $file) {
$filemtime = filemtime($file);
if ($filemtime > $newestTimestamp) {
$newestTimestamp = $filemtime;
}
}

$targetFilename = md5(implode(',', $files) . "|{$hostname}|{$port}|{$newestTimestamp}") . '.css';
$mergeFilesResult = $this->_mergeFiles(
$files,
$targetDir . DS . $targetFilename,
Expand Down

0 comments on commit 1fcf745

Please sign in to comment.