bug #26128 Make kernel build time optionally deterministic (lstrojny)
This PR was merged into the 3.4 branch.
Discussion
----------
Make kernel build time optionally deterministic
| Q | A
| ------------- | ---
| Branch? | master for features / 2.7 up to 4.0 for bug fixes <!-- see below -->
| Bug fix? | yes
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
As part of the effort to enable reproducible builds, this PR allows setting a deterministic build time for the dumped kernel. Parent issue is symfony/symfony#25958.
Commits
-------
48e8249
Make kernel build time optionally deterministic
This commit is contained in:
commit
eb53c7de53
@ -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
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user