Again: Zend OPcache API is restricted by "restrict_api" configuration directive


this topic reappears in 1.3.3, although it should be fixed:

“Zend OPcache API is restricted by “restrict_api” configuration directive”



{% embed 'partials/register.html.twig' with {title:'Grav Register Admin User', classes:'wide'} %}

Cache is disabled in system/config/system.yaml.

This is on a shared hosting so Zend is beyond our control.

(more references had to be removed because of discourse’s limitation for new users)

Drupal developed this fix.
This message has been silenced in grav 7 months ago but still appears in 1.3.3 in an installation via github/composer. Is it necessary to switch to 1.x-dev?

Same with the development branch:

“An exception has been thrown during the rendering of a template (“Zend OPcache API is restricted by “restrict_api” configuration directive”).”

in user/themes/antimatter/templates/partials/base.html.twig:54:
{% include ‘partials/navigation.html.twig’ %}

The original fix is still there:

It should fail silently because of the @ prefix before the function call.

Hi, i’ve been hit by this as well. And like others, i’m also on shared hosting, so no real control over my php environment. I got it working though.

In addition to this @-prefixed opcache line mentioned in previous posts:

… i also found another opcache line in my /www tree:

I’ve @-prefixed the opcached line in there and now my site is up again. I have no clue of what i’m doing actually and what fallout there might be from that change, but for now, it works

1 Like

Just a note — I got this error after enabling PHP 7.2 on my server, reverting to 7.1 fixed it.

Same here, running Serverpilot on Linode — changing to php 7.2 throws this error

An exception has been thrown during the rendering of a template (“Zend OPcache API is restricted by “restrict_api” configuration directive”).

Change back to 7.1 / 7.0 and no problems…

same here Grav 1.4.2, no matter the php 7.* version
the @ helped though (@opcache_invalidate($file->filename(), true):wink:

but kinda stupid to change the core

OK, there is a proper fix, that I came across while trying to solve this on a serverpilot controlled digital ocean droplet:

The error is caused by a configuration in php.ini for opcache:

To resolve, simply edit this setting in your php.ini (or relevant configuration file) for opcache settings. In my case I had an /etc/php7.2-sp/conf.d/opcache.ini file that contained:


I just changed this to:


and restarted PHP FPM with: sudo service php7.2-fpm-sp restart

I just updated to latest Grav v1.4.4 - Admin v1.7.2
and the problem is back
adding @ on line 70 like in previous case solved the issue.

I’ve same problem when i update my serverpilot php from 7.2 to 7.3
How can i fix it ?