Skip to content

Commit 5222643

Browse files
ruudkfabpot
authored andcommitted
Don’t compile when Opcache is not enabled on CLI
1 parent d93024b commit 5222643

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected function doSave(array $values, $lifetime)
9393
$ok = true;
9494
$data = array($lifetime ? time() + $lifetime : PHP_INT_MAX, '');
9595

96-
foreach ($values as $id => $value) {
96+
foreach ($values as $key => $value) {
9797
if (null === $value || is_object($value)) {
9898
$value = serialize($value);
9999
} elseif (is_array($value)) {
@@ -109,13 +109,16 @@ protected function doSave(array $values, $lifetime)
109109
$value = serialize($value);
110110
}
111111
} elseif (!is_scalar($value)) {
112-
throw new InvalidArgumentException(sprintf('Value of type "%s" is not serializable', $key, gettype($value)));
112+
throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, gettype($value)));
113113
}
114114

115115
$data[1] = $value;
116-
$file = $this->getFile($id, true);
116+
$file = $this->getFile($key, true);
117117
$ok = $this->write($file, '<?php return '.var_export($data, true).';') && $ok;
118-
@opcache_compile_file($file);
118+
119+
if ('cli' !== PHP_SAPI || ini_get('opcache.enable_cli')) {
120+
@opcache_compile_file($file);
121+
}
119122
}
120123

121124
return $ok;

0 commit comments

Comments
 (0)