8000 Don’t compile when Opcache is not enabled on CLI by ruudk · Pull Request #20883 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected function doSave(array $values, $lifetime)
$ok = true;
$data = array($lifetime ? time() + $lifetime : PHP_INT_MAX, '');

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

$data[1] = $value;
$file = $this->getFile($id, true);
$file = $this->getFile($key, true);
$ok = $this->write($file, '<?php return '.var_export($data, true).';') && $ok;
@opcache_compile_file($file);

if ('cli' !== PHP_SAPI || ini_get('opcache.enable_cli')) {
@opcache_compile_file($file);
}
}

return $ok;
Expand Down
0