Skip to content

Commit 436d5e4

Browse files
committed
bug symfony#23195 [FrameworkBundle] [Command] Clean bundle directory, fixes symfony#23177 (NicolasPion)
This PR was squashed before being merged into the 2.7 branch (closes symfony#23195). Discussion ---------- [FrameworkBundle] [Command] Clean bundle directory, fixes symfony#23177 | Q | A | ------------- | --- | Branch? | 2.7 <!-- see comment below --> | Bug fix? | yes | New feature? | no <!-- don't forget updating src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget updating UPGRADE-*.md files --> | Tests pass? | no | Fixed tickets | symfony#23177 | License | MIT This PR fix symfony#23177 when running an assets:install, it will remove directorys who do not have anymore a valid Bundle Commits ------- 180f178 [FrameworkBundle] [Command] Clean bundle directory, fixes symfony#23177
2 parents c8884e7 + 180f178 commit 436d5e4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8989
$output->writeln('Installing assets as <comment>hard copies</comment>.');
9090
}
9191

92+
$validAssetDirs = array();
9293
foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
9394
if (is_dir($originDir = $bundle->getPath().'/Resources/public')) {
9495
$targetDir = $bundlesDir.preg_replace('/bundle$/', '', strtolower($bundle->getName()));
@@ -131,6 +132,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
131132
} else {
132133
$this->hardCopy($originDir, $targetDir);
133134
}
135+
$validAssetDirs[] = $targetDir;
136+
}
137+
}
138+
// remove the assets of the bundles that no longer exist
139+
foreach (new \FilesystemIterator($bundlesDir) as $dir) {
140+
if (!in_array($dir, $validAssetDirs)) {
141+
$filesystem->remove($dir);
134142
}
135143
}
136144
}

0 commit comments

Comments
 (0)