ElkArte Community

Title: Cannot change Cookies and Sessions settings
Post by: radu81 on May 03, 2018, 03:06:28 am
I think my problem related to unread replies (https://www.elkarte.net/community/index.php?topic=5177.0) which are not working is related to sessions, so I tried to change settings in Cookies and Sessions, but I cannot save, I get this error: Zend OPcache API is restricted by "restrict_api" configuration directive
I tried to disable OPcache but nothing changed.
Title: Re: Cannot change Cookies and Sessions settings
Post by: Spuds on May 03, 2018, 08:34:51 am
Did you check the actual settings.php file to see if it changed?

I'm hoping it was changed and the above error is due to your setup restricting access to the opcache_invalidate function.   That means your changes will not show up until the cache naturally invalidates the file.
Title: Re: Cannot change Cookies and Sessions settings
Post by: radu81 on May 03, 2018, 08:55:45 am
I didn't checked settings.php file. I switched to php 5.6, made the edits, than switched back to php 7.2. Settings were saved in this way
Title: Re: Cannot change Cookies and Sessions settings
Post by: Spuds on May 03, 2018, 09:30:39 am
OK .... well from reading my guess is that the check we do

if (function_exists('opcache_invalidate'))

is not sufficient and has a couple of bugs.  First  the function existing does not mean that you are using the opcache.  Second even if it exists, it does not mean we can use it.

So I'm thinking we need to change that to be

Code: [Select]
if (extension_loaded('Zend OPcache') && ini_get('opcache.enable') && stripos(BOARDDIR, ini_get('opcache.restrict_api')) !== 0)

Which checks that the extension is available, that we have enabled it and that we are not restricted from using certain functions (like opcache_invalidate).   This will prevent the error HOWEVER you will still have the cache issue as the cache is using the old file for "some time" based on the values you are running the opcode under.