[FrameworkBundle] Fixes invalid serialized objects in cache
This commit is contained in:
parent
0e7b5fb3bb
commit
d1f5d25483
@ -104,10 +104,31 @@ EOF
|
||||
|
||||
$warmer->warmUp($warmupDir);
|
||||
|
||||
foreach (Finder::create()->files()->name('*.meta')->in($warmupDir) as $file) {
|
||||
// fix meta references to the Kernel
|
||||
$content = preg_replace(
|
||||
'/C\:\d+\:"'.preg_quote($class.$this->getTempKernelSuffix(), '"/').'"/',
|
||||
sprintf('C:%s:"%s"', strlen($class), $class),
|
||||
file_get_contents($file)
|
||||
);
|
||||
|
||||
// fix meta references to cache files
|
||||
$realWarmupDir = substr($warmupDir, 0, -4);
|
||||
$content = preg_replace_callback(
|
||||
'/s\:\d+\:"'.preg_quote($warmupDir, '/').'([^"]+)"/',
|
||||
function (array $matches) use ($realWarmupDir) {
|
||||
$path = $realWarmupDir.$matches[1];
|
||||
return sprintf('s:%s:"%s"', strlen($path), $path);
|
||||
},
|
||||
$content
|
||||
);
|
||||
|
||||
file_put_contents($file, $content);
|
||||
}
|
||||
|
||||
// fix container files and classes
|
||||
$regex = '/'.preg_quote($this->getTempKernelSuffix(), '/').'/';
|
||||
$finder = new Finder();
|
||||
foreach ($finder->files()->name(get_class($kernel->getContainer()).'*')->in($warmupDir) as $file) {
|
||||
foreach (Finder::create()->files()->name(get_class($kernel->getContainer()).'*')->in($warmupDir) as $file) {
|
||||
$content = file_get_contents($file);
|
||||
$content = preg_replace($regex, '', $content);
|
||||
|
||||
@ -117,16 +138,6 @@ EOF
|
||||
file_put_contents(preg_replace($regex, '', $file), $content);
|
||||
unlink($file);
|
||||
}
|
||||
|
||||
// fix meta references to the Kernel
|
||||
foreach ($finder->files()->name('*.meta')->in($warmupDir) as $file) {
|
||||
$content = preg_replace(
|
||||
'/C\:\d+\:"'.preg_quote($class.$this->getTempKernelSuffix(), '"/').'"/',
|
||||
sprintf('C:%s:"%s"', strlen($class), $class),
|
||||
file_get_contents($file)
|
||||
);
|
||||
file_put_contents($file, $content);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getTempKernelSuffix()
|
||||
|
@ -246,8 +246,8 @@ class FrameworkExtension extends Extension
|
||||
$loader->load('routing.xml');
|
||||
|
||||
$container->setParameter('router.resource', $config['resource']);
|
||||
$container->setParameter('router.cache_class_prefix', $container->getParameter('kernel.name').ucfirst($container->getParameter('kernel.environment')));
|
||||
$router = $container->findDefinition('router.default');
|
||||
|
||||
$argument = $router->getArgument(2);
|
||||
$argument['strict_requirements'] = $config['strict_requirements'];
|
||||
if (isset($config['type'])) {
|
||||
|
@ -19,8 +19,8 @@
|
||||
<parameter key="router.options.matcher_base_class">Symfony\Bundle\FrameworkBundle\Routing\RedirectableUrlMatcher</parameter>
|
||||
<parameter key="router.options.matcher_dumper_class">Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper</parameter>
|
||||
<parameter key="router.cache_warmer.class">Symfony\Bundle\FrameworkBundle\CacheWarmer\RouterCacheWarmer</parameter>
|
||||
<parameter key="router.options.matcher.cache_class">%kernel.name%%kernel.environment%UrlMatcher</parameter>
|
||||
<parameter key="router.options.generator.cache_class">%kernel.name%%kernel.environment%UrlGenerator</parameter>
|
||||
<parameter key="router.options.matcher.cache_class">%router.cache_class_prefix%UrlMatcher</parameter>
|
||||
<parameter key="router.options.generator.cache_class">%router.cache_class_prefix%UrlGenerator</parameter>
|
||||
<parameter key="router_listener.class">Symfony\Component\HttpKernel\EventListener\RouterListener</parameter>
|
||||
<parameter key="router.request_context.host">localhost</parameter>
|
||||
<parameter key="router.request_context.scheme">http</parameter>
|
||||
|
Reference in New Issue
Block a user