bug #3087 Extend opcache check if it is enabled (vosco88)

This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes #3087).

Discussion
----------

Extend opcache check if it is enabled

When trying to deploy October on shared hosting (www.websupport.sk) I received following error when accessing the frontend pages - ErrorException:> Zend OPcache API is restricted by "restrict_api" configuration directive.
Backend was working normally.
I propose the following change to check not only if the opcache_invalidate exists but also if opcache is enabled.
The change was also needed in octobercms files, but to correspond I am also proposing to add it directly to twig.

Commits
-------

6e68bd08 Extend opcache check if it is enabled
This commit is contained in:
Fabien Potencier
2019-07-12 09:09:49 +03:00
+1 -1
View File
@@ -67,7 +67,7 @@ class FilesystemCache implements CacheInterface
if (self::FORCE_BYTECODE_INVALIDATION == ($this->options & self::FORCE_BYTECODE_INVALIDATION)) {
// Compile cached file into bytecode cache
if (\function_exists('opcache_invalidate')) {
if (\function_exists('opcache_invalidate') && ini_get('opcache.enable')) {
opcache_invalidate($key, true);
} elseif (\function_exists('apc_compile_file')) {
apc_compile_file($key);