Skip to content

Commit 638533b

Browse files
minor symfony#20902 [Cache] Improve performances into foreach (PhpFilesAdapter) (hadjedjvincent)
This PR was squashed before being merged into the 3.2 branch (closes symfony#20902). Discussion ---------- [Cache] Improve performances into foreach (PhpFilesAdapter) | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | License | MIT Let's prevent some useless call to be made into this foreach (ini_get) Commits ------- 7e4573b [Cache] Improve performances into foreach (PhpFilesAdapter)
2 parents c41cfcb + 7e4573b commit 638533b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ protected function doSave(array $values, $lifetime)
9292
{
9393
$ok = true;
9494
$data = array($lifetime ? time() + $lifetime : PHP_INT_MAX, '');
95+
$allowCompile = 'cli' !== PHP_SAPI || ini_get('opcache.enable_cli');
9596

9697
foreach ($values as $key => $value) {
9798
if (null === $value || is_object($value)) {
@@ -116,7 +117,7 @@ protected function doSave(array $values, $lifetime)
116117
$file = $this->getFile($key, true);
117118
$ok = $this->write($file, '<?php return '.var_export($data, true).';') && $ok;
118119

119-
if ('cli' !== PHP_SAPI || ini_get('opcache.enable_cli')) {
120+
if ($allowCompile) {
120121
@opcache_compile_file($file);
121122
}
122123
}

0 commit comments

Comments
 (0)