Skip to content

Commit d3f4a7d

Browse files
author
Karpenko, Oleksandr
committed
MAGETWO-69515: Static files are deployed too slow for multiple locales
1 parent f5c8add commit d3f4a7d

File tree

2 files changed

+25
-42
lines changed

2 files changed

+25
-42
lines changed

app/code/Magento/Deploy/Package/Processor/PreProcessor/Less.php

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,34 @@ private function hasOverrides(PackageFile $parentFile, Package $package)
127127
$parentFile->getPackage()->getPath(),
128128
$parentFile->getExtension()
129129
);
130-
$parentFiles = $this->collectFileMap($parentFile->getFileName(), $map);
131-
$currentPackageLessFiles = $package->getFilesByType('less');
132-
$currentPackageCssFiles = $package->getFilesByType('css');
133130
/** @var PackageFile[] $currentPackageFiles */
134-
$currentPackageFiles = array_merge($currentPackageLessFiles, $currentPackageCssFiles);
131+
$currentPackageFiles = array_merge($package->getFilesByType('less'), $package->getFilesByType('css'));
135132

136133
foreach ($currentPackageFiles as $file) {
137-
if (in_array($file->getDeployedFileName(), $parentFiles)) {
134+
if ($this->inParentFiles($file->getDeployedFileName(), $parentFile->getFileName(), $map)) {
138135
return true;
139136
}
140137
}
138+
return false;
139+
}
141140

142-
$intersections = array_intersect($parentFiles, array_keys($currentPackageFiles));
143-
if ($intersections) {
144-
return true;
141+
/**
142+
* @param string $fileName
143+
* @param string $parentFile
144+
* @param array $map
145+
* @return bool
146+
*/
147+
private function inParentFiles($fileName, $parentFile, $map)
148+
{
149+
if (isset($map[$parentFile])) {
150+
if (in_array($fileName, $map[$parentFile])) {
151+
return true;
152+
} else {
153+
foreach ($map[$parentFile] as $pFile) {
154+
return $this->inParentFiles($fileName, $pFile, $map);
155+
}
156+
}
145157
}
146-
147158
return false;
148159
}
149160

@@ -186,25 +197,6 @@ private function buildMap($filePath, $packagePath, $contentType)
186197
return $this->map;
187198
}
188199

189-
/**
190-
* Flatten map tree into simple array
191-
*
192-
* Original map file information structure in form of tree,
193-
* and to have checking of overridden files simpler we need to flatten that tree
194-
*
195-
* @param string $fileName
196-
* @param array $map
197-
* @return array
198-
*/
199-
private function collectFileMap($fileName, array $map)
200-
{
201-
$result = isset($map[$fileName]) ? $map[$fileName] : [];
202-
foreach ($result as $fName) {
203-
$result = array_merge($result, $this->collectFileMap($fName, $map));
204-
}
205-
return array_unique($result);
206-
}
207-
208200
/**
209201
* Return normalized path
210202
*

app/code/Magento/Deploy/Process/Queue.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -187,24 +187,15 @@ private function assertAndExecute($name, array & $packages, array $packageJob)
187187
{
188188
/** @var Package $package */
189189
$package = $packageJob['package'];
190-
$parentPackagesDeployed = true;
191190
if ($package->getParent() && $package->getParent() !== $package) {
192-
if (!$this->isDeployed($package->getParent())) {
193-
$parentPackagesDeployed = false;
194-
} else {
195-
$dependencies = $packageJob['dependencies'];
196-
foreach ($dependencies as $parentPackage) {
197-
if (!$this->isDeployed($parentPackage)) {
198-
$parentPackagesDeployed = false;
199-
break;
200-
}
191+
foreach ($packageJob['dependencies'] as $dependencyName => $dependency) {
192+
if (!$this->isDeployed($dependency)) {
193+
$this->assertAndExecute($dependencyName, $packages, $packages[$dependencyName]);
201194
}
202195
}
203196
}
204-
if (
205-
$parentPackagesDeployed
206-
&& ($this->maxProcesses < 2 || (count($this->inProgress) < $this->maxProcesses))
207-
) {
197+
if (!$this->isDeployed($package)
198+
&& ($this->maxProcesses < 2 || (count($this->inProgress) < $this->maxProcesses))) {
208199
unset($packages[$name]);
209200
$this->execute($package);
210201
}

0 commit comments

Comments
 (0)