Make kernel build time optionally deterministic

This commit is contained in:
Lars Strojny 2018-02-10 00:41:50 +01:00
parent 05a045268f
commit 48e8249da9
2 changed files with 3 additions and 1 deletions

View File

@ -119,6 +119,7 @@ class PhpDumper extends Dumper
'debug' => true,
'hot_path_tag' => 'container.hot_path',
'inline_class_loader_parameter' => 'container.dumper.inline_class_loader',
'build_time' => time(),
), $options);
$this->namespace = $options['namespace'];
@ -216,7 +217,7 @@ EOF;
array_pop($code);
$code["Container{$hash}/{$options['class']}.php"] = substr_replace($files[$options['class'].'.php'], "<?php\n\nnamespace Container{$hash};\n", 0, 6);
$namespaceLine = $this->namespace ? "\nnamespace {$this->namespace};\n" : '';
$time = time();
$time = $options['build_time'];
$id = hash('crc32', $hash.$time);
$code[$options['class'].'.php'] = <<<EOF

View File

@ -855,6 +855,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
'as_files' => true,
'debug' => $this->debug,
'inline_class_loader_parameter' => \PHP_VERSION_ID >= 70000 && !$this->loadClassCache && !class_exists(ClassCollectionLoader::class, false) ? 'container.dumper.inline_class_loader' : null,
'build_time' => $container->hasParameter('kernel.container_build_time') ? $container->getParameter('kernel.container_build_time') : time(),
));
$rootCode = array_pop($content);