@@ -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
$ filesystem ->remove ($ warmupDir );
@@ -100,8 +102,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
100
102
*/
101
103
protected function warmup ($ warmupDir , $ realCacheDir , $ enableOptionalWarmers = true )
102
104
{
103
- $ this ->getContainer ()->get ('filesystem ' )->remove ($ warmupDir );
104
-
105
105
// create a temporary kernel
106
106
$ realKernel = $ this ->getContainer ()->get ('kernel ' );
107
107
$ realKernelClass = get_class ($ realKernel );
0 commit comments