@@ -54,7 +54,9 @@ protected function configure()
5454 protected function execute (InputInterface $ input , OutputInterface $ output )
5555 {
5656 $ 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 ) ? '+ ' : '~ ' );
5860 $ filesystem = $ this ->getContainer ()->get ('filesystem ' );
5961
6062 if (!is_writable ($ realCacheDir )) {
@@ -75,7 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
7577 // the warmup cache dir name must have the same length than the real one
7678 // to avoid the many problems in serialized resources files
7779 $ realCacheDir = realpath ($ realCacheDir );
78- $ warmupDir = substr ($ realCacheDir , 0 , -1 ).'_ ' ;
80+ $ warmupDir = substr ($ realCacheDir , 0 , -1 ).( '_ ' === substr ( $ realCacheDir , - 1 ) ? ' - ' : ' _ ' ) ;
7981
8082 if ($ filesystem ->exists ($ warmupDir )) {
8183 $ filesystem ->remove ($ warmupDir );
@@ -100,8 +102,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
100102 */
101103 protected function warmup ($ warmupDir , $ realCacheDir , $ enableOptionalWarmers = true )
102104 {
103- $ this ->getContainer ()->get ('filesystem ' )->remove ($ warmupDir );
104-
105105 // create a temporary kernel
106106 $ realKernel = $ this ->getContainer ()->get ('kernel ' );
107107 $ realKernelClass = get_class ($ realKernel );
0 commit comments