Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0b0a8fa

Browse files
[FrameworkBundle][HttpKernel] Fix behavior of cache-warmers regarding cache vs build dirs
1 parent bafe768 commit 0b0a8fa

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ private function warmupOptionals(string $cacheDir, string $warmupDir, SymfonySty
245245
$warmer = $kernel->getContainer()->get('cache_warmer');
246246
// non optional warmers already ran during container compilation
247247
$warmer->enableOnlyOptionalWarmers();
248-
$preload = (array) $warmer->warmUp($cacheDir, $warmupDir, $io);
248+
$preload = (array) $warmer->warmUp($cacheDir, null, $io);
249249

250250
if ($preload && file_exists($preloadFile = $warmupDir.'/'.$kernel->getContainer()->getParameter('kernel.container_class').'.preload.php')) {
251251
Preloader::append($preloadFile, $preload);

src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerInterface.php

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ interface CacheWarmerInterface extends WarmableInterface
2626
* A warmer should return true if the cache can be
2727
* generated incrementally and on-demand.
2828
*
29+
* Note that optional cache-warmers are never called
30+
* with a $buildDir {@see WarmableInterface::warmUp()}
31+
*
2932
* @return bool
3033
*/
3134
public function isOptional();

src/Symfony/Component/HttpKernel/Kernel.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -539,10 +539,10 @@ protected function initializeContainer()
539539
touch($oldContainerDir.'.legacy');
540540
}
541541

542-
$preload = $this instanceof WarmableInterface ? (array) $this->warmUp($this->container->getParameter('kernel.cache_dir'), $buildDir) : [];
542+
$preload = $this instanceof WarmableInterface ? (array) $this->warmUp($buildDir, $buildDir) : [];
543543

544544
if ($this->container->has('cache_warmer')) {
545-
$preload = array_merge($preload, (array) $this->container->get('cache_warmer')->warmUp($this->container->getParameter('kernel.cache_dir'), $buildDir));
545+
$preload = array_merge($preload, (array) $this->container->get('cache_warmer')->warmUp($buildDir, $buildDir));
546546
}
547547

548548
if ($preload && file_exists($preloadFile = $buildDir.'/'.$class.'.preload.php')) {

0 commit comments

Comments
 (0)