@@ -104,10 +104,31 @@ protected function warmup($warmupDir, $enableOptionalWarmers = true)
104
104
105
105
$ warmer ->warmUp ($ warmupDir );
106
106
107
+ foreach (Finder::create ()->files ()->name ('*.meta ' )->in ($ warmupDir ) as $ file ) {
108
+ // fix meta references to the Kernel
109
+ $ content = preg_replace (
110
+ '/C\:\d+\:" ' .preg_quote ($ class .$ this ->getTempKernelSuffix (), '"/ ' ).'"/ ' ,
111
+ sprintf ('C:%s:"%s" ' , strlen ($ class ), $ class ),
112
+ file_get_contents ($ file )
113
+ );
114
+
115
+ // fix meta references to cache files
116
+ $ realWarmupDir = substr ($ warmupDir , 0 , -4 );
117
+ $ content = preg_replace_callback (
118
+ '/s\:\d+\:" ' .preg_quote ($ warmupDir , '/ ' ).'([^"]+)"/ ' ,
119
+ function (array $ matches ) use ($ realWarmupDir ) {
120
+ $ path = $ realWarmupDir .$ matches [1 ];
121
+ return sprintf ('s:%s:"%s" ' , strlen ($ path ), $ path );
122
+ },
123
+ $ content
124
+ );
125
+
126
+ file_put_contents ($ file , $ content );
127
+ }
128
+
107
129
// fix container files and classes
108
130
$ regex = '/ ' .preg_quote ($ this ->getTempKernelSuffix (), '/ ' ).'/ ' ;
109
- $ finder = new Finder ();
110
- foreach ($ finder ->files ()->name (get_class ($ kernel ->getContainer ()).'* ' )->in ($ warmupDir ) as $ file ) {
131
+ foreach (Finder::create ()->files ()->name (get_class ($ kernel ->getContainer ()).'* ' )->in ($ warmupDir ) as $ file ) {
111
132
$ content = file_get_contents ($ file );
112
133
$ content = preg_replace ($ regex , '' , $ content );
113
134
@@ -117,16 +138,6 @@ protected function warmup($warmupDir, $enableOptionalWarmers = true)
117
138
file_put_contents (preg_replace ($ regex , '' , $ file ), $ content );
118
139
unlink ($ file );
119
140
}
120
-
121
- // fix meta references to the Kernel
122
- foreach ($ finder ->files ()->name ('*.meta ' )->in ($ warmupDir ) as $ file ) {
123
- $ content = preg_replace (
124
- '/C\:\d+\:" ' .preg_quote ($ class .$ this ->getTempKernelSuffix (), '"/ ' ).'"/ ' ,
125
- sprintf ('C:%s:"%s" ' , strlen ($ class ), $ class ),
126
- file_get_contents ($ file )
127
- );
128
- file_put_contents ($ file , $ content );
129
- }
130
141
}
131
142
132
143
protected function getTempKernelSuffix ()
0 commit comments