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