@@ -137,14 +137,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
137
137
if ($ output ->isVerbose ()) {
138
138
$ io ->comment ('Warming up optional cache... ' );
139
139
}
140
- $ warmer = $ kernel ->getContainer ()->get ('cache_warmer ' );
141
- // non optional warmers already ran during container compilation
142
- $ warmer ->enableOnlyOptionalWarmers ();
143
- $ preload = (array ) $ warmer ->warmUp ($ realCacheDir );
144
-
145
- if ($ preload && file_exists ($ preloadFile = $ realCacheDir .'/ ' .$ kernel ->getContainer ()->getParameter ('kernel.container_class ' ).'.preload.php ' )) {
146
- Preloader::append ($ preloadFile , $ preload );
147
- }
140
+ $ this ->warmupOptionals ($ realCacheDir );
148
141
}
149
142
} else {
150
143
$ fs ->mkdir ($ warmupDir );
@@ -153,7 +146,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
153
146
if ($ output ->isVerbose ()) {
154
147
$ io ->comment ('Warming up cache... ' );
155
148
}
156
- $ this ->warmup ($ warmupDir , $ realCacheDir , !$ input ->getOption ('no-optional-warmers ' ));
149
+ $ this ->warmup ($ warmupDir , $ realBuildDir );
150
+
151
+ if (!$ input ->getOption ('no-optional-warmers ' )) {
152
+ if ($ output ->isVerbose ()) {
153
+ $ io ->comment ('Warming up optional cache... ' );
154
+ }
155
+ $ this ->warmupOptionals ($ realCacheDir );
156
+ }
157
157
}
158
158
159
159
if (!$ fs ->exists ($ warmupDir .'/ ' .$ containerDir )) {
@@ -227,7 +227,7 @@ private function isNfs(string $dir): bool
227
227
return false ;
228
228
}
229
229
230
- private function warmup (string $ warmupDir , string $ realBuildDir, bool $ enableOptionalWarmers = true )
230
+ private function warmup (string $ warmupDir , string $ realBuildDir): void
231
231
{
232
232
// create a temporary kernel
233
233
$ kernel = $ this ->getApplication ()->getKernel ();
@@ -236,18 +236,6 @@ private function warmup(string $warmupDir, string $realBuildDir, bool $enableOpt
236
236
}
237
237
$ kernel ->reboot ($ warmupDir );
238
238
239
- // warmup temporary dir
240
- if ($ enableOptionalWarmers ) {
241
- $ warmer = $ kernel ->getContainer ()->get ('cache_warmer ' );
242
- // non optional warmers already ran during container compilation
243
- $ warmer ->enableOnlyOptionalWarmers ();
244
- $ preload = (array ) $ warmer ->warmUp ($ warmupDir );
245
-
246
- if ($ preload && file_exists ($ preloadFile = $ warmupDir .'/ ' .$ kernel ->getContainer ()->getParameter ('kernel.container_class ' ).'.preload.php ' )) {
247
- Preloader::append ($ preloadFile , $ preload );
248
- }
249
- }
250
-
251
239
// fix references to cached files with the real cache directory name
252
240
$ search = [$ warmupDir , str_replace ('\\' , '\\\\' , $ warmupDir )];
253
241
$ replace = str_replace ('\\' , '/ ' , $ realBuildDir );
@@ -258,4 +246,17 @@ private function warmup(string $warmupDir, string $realBuildDir, bool $enableOpt
258
246
}
259
247
}
260
248
}
249
+
250
+ private function warmupOptionals (string $ realCacheDir ): void
251
+ {
252
+ $ kernel = $ this ->getApplication ()->getKernel ();
253
+ $ warmer = $ kernel ->getContainer ()->get ('cache_warmer ' );
254
+ // non optional warmers already ran during container compilation
255
+ $ warmer ->enableOnlyOptionalWarmers ();
256
+ $ preload = (array ) $ warmer ->warmUp ($ realCacheDir );
257
+
258
+ if ($ preload && file_exists ($ preloadFile = $ realCacheDir .'/ ' .$ kernel ->getContainer ()->getParameter ('kernel.container_class ' ).'.preload.php ' )) {
259
+ Preloader::append ($ preloadFile , $ preload );
260
+ }
261
+ }
261
262
}
0 commit comments