@@ -54,7 +54,9 @@ protected function configure()
54
54
protected function execute (InputInterface $ input , OutputInterface $ output )
55
55
{
56
56
$ realCacheDir = $ this ->getContainer ()->getParameter ('kernel.cache_dir ' );
57
- $ oldCacheDir = $ realCacheDir .'_old ' ;
57
+ // the old cache dir name must not be longer than the real one to avoid exceeding
58
+ // the maximum length of a directory or file path within it (esp. Windows MAX_PATH)
59
+ $ oldCacheDir = substr ($ realCacheDir , 0 , -1 ).('~ ' === substr ($ realCacheDir , -1 ) ? '+ ' : '~ ' );
58
60
$ filesystem = $ this ->getContainer ()->get ('filesystem ' );
59
61
60
62
if (!is_writable ($ realCacheDir )) {
@@ -75,7 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
75
77
// the warmup cache dir name must have the same length than the real one
76
78
// to avoid the many problems in serialized resources files
77
79
$ realCacheDir = realpath ($ realCacheDir );
78
- $ warmupDir = substr ($ realCacheDir , 0 , -1 ).'_ ' ;
80
+ $ warmupDir = substr ($ realCacheDir , 0 , -1 ).( '_ ' === substr ( $ realCacheDir , - 1 ) ? ' - ' : ' _ ' ) ;
79
81
80
82
if ($ filesystem ->exists ($ warmupDir )) {
81
83
if ($ output ->isVerbose ()) {
@@ -114,8 +116,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
114
116
*/
115
117
protected function warmup ($ warmupDir , $ realCacheDir , $ enableOptionalWarmers = true )
116
118
{
117
- $ this ->getContainer ()->get ('filesystem ' )->remove ($ warmupDir );
118
-
119
119
// create a temporary kernel
120
120
$ realKernel = $ this ->getContainer ()->get ('kernel ' );
121
121
$ realKernelClass = get_class ($ realKernel );
0 commit comments