Skip to content

Commit cd47130

Browse files
committed
Don’t compile when opcache is not enabled on CLI
1 parent ecc8b95 commit cd47130

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,22 @@ protected function doSave(array $values, $lifetime)
115115
$data[1] = $value;
116116
$file = $this->getFile($id, true);
117117
$ok = $this->write($file, '<?php return '.var_export($data, true).';') && $ok;
118-
@opcache_compile_file($file);
118+
119+
$this->compileFile($file);
119120
}
120121

121122
return $ok;
122123
}
124+
125+
/**
126+
* @param string $file
127+
*/
128+
private function compileFile($file)
129+
{
130+
if ('cli' === php_sapi_name() && !ini_get('opcache.enable_cli')) {
131+
return;
132+
}
133+
134+
@opcache_compile_file($file);
135+
}
123136
}

0 commit comments

Comments
 (0)