Fix "Nextcloud is not allowed to use the OPcache API" warning #31415
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
This aims to fix "Nextcloud is not allowed to use the OPcache API" warning being displayed even though OPcache is configured and running fine.
With the latest update to 23 the above warning appeared but there were no warnings or any issues before the update.
So i dug into this and found the string comparison to be causing the warning: in my setup
opcache.restrict_apihas a trailing slash whereasOC::$SERVEROOThas not. 🙈To be honest i wasn't sure wether to add a slash to the server root for comparison or to remove the trailing slash and in the end i decided for the latter. Also please note that i'm not an every day PHP developer at all so don't mind if this attempt of solving the issue is not the right way to fix it at all. I'm just trying to follow the idea of submitting patches instead of just filing bugs and it was quite interesting to read through all of this. 😉
Why is there a trailing slash in my
opcache.restrict_apiand why dont i just remove it? I'm running a self-hosted Nextcloud instance on a server that is otherwise managed using Froxlor Server Management Panel. With this management panel theopcache.restrict_apigets somewhat dynamically configured per virtual host using a placeholder{DOCUMENT_ROOT}wich in turn has this trailing slash.