Skip to content

Commit 7e4573b

Browse files
hadjedjvincentnicolas-grekas
authored andcommitted
[Cache] Improve performances into foreach (PhpFilesAdapter)
1 parent c41cfcb commit 7e4573b

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)