diff --git a/vendor/magento/module-deploy/Collector/Collector.php b/vendor/magento/module-deploy/Collector/Collector.php index b09001a7ac0..441d165f679 100644 --- a/vendor/magento/module-deploy/Collector/Collector.php +++ b/vendor/magento/module-deploy/Collector/Collector.php @@ -93,6 +93,9 @@ class Collector implements CollectorInterface if ($file->getModule() && !$this->moduleManager->isEnabled($file->getModule())) { continue; } + if (!$file->getFileName()) { + continue; + } $file->setDeployedFileName($this->fileNameResolver->resolve($file->getFileName())); $params = $this->getParams($file); $packagePath = "{$params['area']}/{$params['theme']}/{$params['locale']}"; diff --git a/vendor/magento/module-deploy/Package/Processor/PreProcessor/Css.php b/vendor/magento/module-deploy/Package/Processor/PreProcessor/Css.php index 42775a2e2f6..6d0ef0404db 100644 --- a/vendor/magento/module-deploy/Package/Processor/PreProcessor/Css.php +++ b/vendor/magento/module-deploy/Package/Processor/PreProcessor/Css.php @@ -120,6 +120,20 @@ class Css implements ProcessorInterface return false; } + /** + * See if given path is local or remote URL + * + * @param string $path + * @return bool + */ + private function isLocal(string $path): bool + { + $pattern = '{^(file://(?!//)|/(?!/)|/?[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i'; + $result = preg_match($pattern, $path); + + return is_int($result) ? (bool) $result : true; + } + /** * Build map file * @@ -135,13 +149,22 @@ class Css implements ProcessorInterface $imports = []; $this->map[$fullPath] = []; - $content = $this->staticDir->readFile($this->minification->addMinifiedSign($fullPath)); + $tmpFilename = $this->minification->addMinifiedSign($fullPath); + if ($this->staticDir->isReadable($tmpFilename)) { + $content = $this->staticDir->readFile($tmpFilename); + } else { + $content = ''; + } $callback = function ($matchContent) use ($packagePath, $filePath, & $imports) { - $importRelPath = $this->normalize(pathinfo($filePath, PATHINFO_DIRNAME) . '/' . $matchContent['path']); - $imports[$importRelPath] = $this->normalize( - $packagePath . '/' . pathinfo($filePath, PATHINFO_DIRNAME) . '/' . $matchContent['path'] - ); + if ($this->isLocal($matchContent['path'])) { + $importRelPath = $this->normalize( + pathinfo($filePath, PATHINFO_DIRNAME) . '/' . $matchContent['path'] + ); + $imports[$importRelPath] = $this->normalize( + $packagePath . '/' . pathinfo($filePath, PATHINFO_DIRNAME) . '/' . $matchContent['path'] + ); + } }; preg_replace_callback(Import::REPLACE_PATTERN, $callback, $content); diff --git a/vendor/magento/module-deploy/Package/Processor/PreProcessor/Less.php b/vendor/magento/module-deploy/Package/Processor/PreProcessor/Less.php index b5fe0c78640..7f6db14ae02 100644 --- a/vendor/magento/module-deploy/Package/Processor/PreProcessor/Less.php +++ b/vendor/magento/module-deploy/Package/Processor/PreProcessor/Less.php @@ -58,6 +58,11 @@ class Less implements ProcessorInterface */ private $map = []; + /** + * @var array + */ + private $pFileCache = []; + /** * Less constructor * @@ -131,6 +136,7 @@ class Less implements ProcessorInterface $currentPackageFiles = array_merge($package->getFilesByType('less'), $package->getFilesByType('css')); foreach ($currentPackageFiles as $file) { + $this->pFileCache = []; if ($this->inParentFiles($file->getDeployedFileName(), $parentFile->getFileName(), $map)) { return true; } @@ -151,6 +157,10 @@ class Less implements ProcessorInterface return true; } else { foreach ($map[$parentFile] as $pFile) { + if (in_array($pFile, $this->pFileCache)) { + continue; + } + $this->pFileCache[] = $pFile; return $this->inParentFiles($fileName, $pFile, $map); } }