Skip to content

Commit 29df8c8

Browse files
authored
Merge pull request #10 from magento-extensibility/master
MAGETWO-54120: Installation fails because of colinmollenhour/cache-backend-redis in replace section
2 parents 109eedd + b5c407a commit 29df8c8

File tree

2 files changed

+36
-13
lines changed

2 files changed

+36
-13
lines changed

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
"symfony/process":"*",
5151
"mikey179/vfsStream":"*"
5252
},
53+
"replace": {
54+
"magento-hackathon/magento-composer-installer": "*"
55+
},
5356
"autoload":{
5457
"psr-0":{
5558
"MagentoHackathon\\Composer\\Magento":"src/"

src/MagentoHackathon/Composer/Magento/Deploystrategy/DeploystrategyAbstract.php

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -308,19 +308,12 @@ public function remove($source, $dest)
308308

309309
// If source doesn't exist, check if it's a glob expression, otherwise we have nothing we can do
310310
if (!file_exists($sourcePath)) {
311-
// Handle globing
312-
$matches = glob($sourcePath);
313-
if ($matches) {
314-
foreach ($matches as $match) {
315-
$newDest = substr($destPath . '/' . basename($match), strlen($this->getDestDir()));
316-
$newDest = ltrim($newDest, ' \\/');
317-
$this->remove(substr($match, strlen($this->getSourceDir())+1), $newDest);
318-
}
319-
return;
320-
}
321-
322-
// Source file isn't a valid file or glob
323-
throw new \ErrorException("Source $sourcePath does not exist");
311+
$this->removeContentOfCategory($sourcePath, $destPath);
312+
return;
313+
} elseif (file_exists($sourcePath) && is_dir($sourcePath)) {
314+
$this->removeContentOfCategory($sourcePath . '/*', $destPath);
315+
@rmdir($destPath);
316+
return;
324317
}
325318

326319
// MP Avoid removing whole folders in case the modman file is not 100% well-written
@@ -331,6 +324,33 @@ public function remove($source, $dest)
331324
self::rmdirRecursive($destPath);
332325
}
333326

327+
/**
328+
* Search and remove content of category
329+
*
330+
* @param string $sourcePath
331+
* @param string $destPath
332+
* @throws \ErrorException
333+
*/
334+
protected function removeContentOfCategory($sourcePath, $destPath)
335+
{
336+
$sourcePath = preg_replace('#/\*$#', '/{,.}*', $sourcePath);
337+
$matches = glob($sourcePath, GLOB_BRACE);
338+
if ($matches) {
339+
foreach ($matches as $match) {
340+
if (preg_match("#/\.{1,2}$#", $match)) {
341+
continue;
342+
}
343+
$newDest = substr($destPath . '/' . basename($match), strlen($this->getDestDir()));
344+
$newDest = ltrim($newDest, ' \\/');
345+
$this->remove(substr($match, strlen($this->getSourceDir())+1), $newDest);
346+
}
347+
return;
348+
}
349+
350+
// Source file isn't a valid file or glob
351+
throw new \ErrorException("Source $sourcePath does not exist");
352+
}
353+
334354
/**
335355
* Remove an empty directory branch up to $stopDir, or stop at the first non-empty parent.
336356
*

0 commit comments

Comments
 (0)