@@ -54,7 +54,6 @@ protected function configure()
5454 */
5555 protected function execute (InputInterface $ input , OutputInterface $ output )
5656 {
57- $ outputIsVerbose = $ output ->isVerbose ();
5857 $ io = new SymfonyStyle ($ input , $ output );
5958
6059 $ realCacheDir = $ this ->getContainer ()->getParameter ('kernel.cache_dir ' );
@@ -78,47 +77,59 @@ protected function execute(InputInterface $input, OutputInterface $output)
7877 if ($ input ->getOption ('no-warmup ' )) {
7978 $ filesystem ->rename ($ realCacheDir , $ oldCacheDir );
8079 } else {
81- // the warmup cache dir name must have the same length than the real one
82- // to avoid the many problems in serialized resources files
83- $ realCacheDir = realpath ($ realCacheDir );
84- $ warmupDir = substr ($ realCacheDir , 0 , -1 ).('_ ' === substr ($ realCacheDir , -1 ) ? '- ' : '_ ' );
85-
86- if ($ filesystem ->exists ($ warmupDir )) {
87- if ($ outputIsVerbose ) {
88- $ io ->comment ('Clearing outdated warmup directory... ' );
89- }
90- $ filesystem ->remove ($ warmupDir );
91- }
92-
93- if ($ outputIsVerbose ) {
94- $ io ->comment ('Warming up cache... ' );
95- }
96- $ this ->warmup ($ warmupDir , $ realCacheDir , !$ input ->getOption ('no-optional-warmers ' ));
80+ @trigger_error ('Calling cache:clear without the --no-warmup option is deprecated since version 3.3. Cache warmup should be done with the cache:warmup command instead. ' , E_USER_DEPRECATED );
9781
98- $ filesystem ->rename ($ realCacheDir , $ oldCacheDir );
99- if ('\\' === DIRECTORY_SEPARATOR ) {
100- sleep (1 ); // workaround for Windows PHP rename bug
101- }
102- $ filesystem ->rename ($ warmupDir , $ realCacheDir );
82+ $ this ->warmupCache ($ input , $ output , $ realCacheDir , $ oldCacheDir );
10383 }
10484
105- if ($ outputIsVerbose ) {
85+ if ($ output -> isVerbose () ) {
10686 $ io ->comment ('Removing old cache directory... ' );
10787 }
10888
10989 $ filesystem ->remove ($ oldCacheDir );
11090
111- if ($ outputIsVerbose ) {
91+ if ($ output -> isVerbose () ) {
11292 $ io ->comment ('Finished ' );
11393 }
11494
11595 $ io ->success (sprintf ('Cache for the "%s" environment (debug=%s) was successfully cleared. ' , $ kernel ->getEnvironment (), var_export ($ kernel ->isDebug (), true )));
11696 }
11797
98+ private function warmupCache (InputInterface $ input , OutputInterface $ output , $ realCacheDir , $ oldCacheDir )
99+ {
100+ $ filesystem = $ this ->getContainer ()->get ('filesystem ' );
101+ $ io = new SymfonyStyle ($ input , $ output );
102+
103+ // the warmup cache dir name must have the same length than the real one
104+ // to avoid the many problems in serialized resources files
105+ $ realCacheDir = realpath ($ realCacheDir );
106+ $ warmupDir = substr ($ realCacheDir , 0 , -1 ).('_ ' === substr ($ realCacheDir , -1 ) ? '- ' : '_ ' );
107+
108+ if ($ filesystem ->exists ($ warmupDir )) {
109+ if ($ output ->isVerbose ()) {
110+ $ io ->comment ('Clearing outdated warmup directory... ' );
111+ }
112+ $ filesystem ->remove ($ warmupDir );
113+ }
114+
115+ if ($ output ->isVerbose ()) {
116+ $ io ->comment ('Warming up cache... ' );
117+ }
118+ $ this ->warmup ($ warmupDir , $ realCacheDir , !$ input ->getOption ('no-optional-warmers ' ));
119+
120+ $ filesystem ->rename ($ realCacheDir , $ oldCacheDir );
121+ if ('\\' === DIRECTORY_SEPARATOR ) {
122+ sleep (1 ); // workaround for Windows PHP rename bug
123+ }
124+ $ filesystem ->rename ($ warmupDir , $ realCacheDir );
125+ }
126+
118127 /**
119128 * @param string $warmupDir
120129 * @param string $realCacheDir
121130 * @param bool $enableOptionalWarmers
131+ *
132+ * @internal to be removed in 4.0
122133 */
123134 protected function warmup ($ warmupDir , $ realCacheDir , $ enableOptionalWarmers = true )
124135 {
@@ -183,6 +194,8 @@ protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = tr
183194 * @param string $warmupDir
184195 *
185196 * @return KernelInterface
197+ *
198+ * @internal to be removed in 4.0
186199 */
187200 protected function getTempKernel (KernelInterface $ parent , $ namespace , $ parentClass , $ warmupDir )
188201 {
0 commit comments