@@ -54,7 +54,6 @@ protected function configure()
54
54
*/
55
55
protected function execute (InputInterface $ input , OutputInterface $ output )
56
56
{
57
- $ outputIsVerbose = $ output ->isVerbose ();
58
57
$ io = new SymfonyStyle ($ input , $ output );
59
58
60
59
$ realCacheDir = $ this ->getContainer ()->getParameter ('kernel.cache_dir ' );
@@ -78,43 +77,53 @@ protected function execute(InputInterface $input, OutputInterface $output)
78
77
if ($ input ->getOption ('no-warmup ' )) {
79
78
$ filesystem ->rename ($ realCacheDir , $ oldCacheDir );
80
79
} 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
- }
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 );
92
81
93
- if ($ outputIsVerbose ) {
94
- $ io ->comment ('Warming up cache... ' );
95
- }
96
- $ this ->warmup ($ warmupDir , $ realCacheDir , !$ input ->getOption ('no-optional-warmers ' ));
97
-
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 );
103
83
}
104
84
105
- if ($ outputIsVerbose ) {
85
+ if ($ output -> isVerbose () ) {
106
86
$ io ->comment ('Removing old cache directory... ' );
107
87
}
108
88
109
89
$ filesystem ->remove ($ oldCacheDir );
110
90
111
- if ($ outputIsVerbose ) {
91
+ if ($ output -> isVerbose () ) {
112
92
$ io ->comment ('Finished ' );
113
93
}
114
94
115
95
$ io ->success (sprintf ('Cache for the "%s" environment (debug=%s) was successfully cleared. ' , $ kernel ->getEnvironment (), var_export ($ kernel ->isDebug (), true )));
116
96
}
117
97
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
+
118
127
/**
119
128
* @param string $warmupDir
120
129
* @param string $realCacheDir
0 commit comments