From 7cb5e161ad668806c43152a4dd43ab999bf45f15 Mon Sep 17 00:00:00 2001 From: Roman Parpalak Date: Tue, 24 Sep 2024 18:01:33 +0300 Subject: [PATCH] Fixed issues with wrong relative URLs in minified CSS if the template is processed in /_admin/index.php after clearing the cache. --- _include/src/Asset/AssetMerge.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/_include/src/Asset/AssetMerge.php b/_include/src/Asset/AssetMerge.php index 1b4de5a..bda398e 100644 --- a/_include/src/Asset/AssetMerge.php +++ b/_include/src/Asset/AssetMerge.php @@ -57,13 +57,15 @@ private function dumpContent(): void foreach ($this->filesToMerge as $fileToMerge) { $minifier->add($fileToMerge); } - $content = $minifier->minify($this->getDumpFilename()); + // Taking realpath here since there are some bugs in dependency for relative paths + $content = $minifier->minify($this->getDumpFilename(true)); } elseif ($this->type === self::TYPE_JS) { $minifier = new Minify\JS(); foreach ($this->filesToMerge as $fileToMerge) { $minifier->add($fileToMerge); } - $content = $minifier->minify($this->getDumpFilename()); + // Taking realpath here since there are some bugs in dependency for relative paths + $content = $minifier->minify($this->getDumpFilename(true)); } else { $content = $this->getConcatenatedContent(); } @@ -94,9 +96,9 @@ private function needToDump(): bool return false; } - private function getDumpFilename(): string + private function getDumpFilename(bool $realPath = false): string { - return sprintf('%s%s', $this->publicCacheDir, $this->getFilename()); + return sprintf('%s%s', $realPath ? realpath($this->publicCacheDir) . '/' : $this->publicCacheDir, $this->getFilename()); } private function getHashFilename(): string