Skip to content

ContextErrorException: Warning: Zend OPcache API is restricted by "restrict_api" configuration #25985

@kevinveenbirkenbach

Description

@kevinveenbirkenbach
Q A
Bug report? yes
Feature request? no
BC Break report? yes
RFC? yes
Symfony version 3.4

If opcache.restrict_api is set, Line 143 in https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Debug/DebugClassLoader.php throws the follow exception if you execute composer.phar;

`Warning: Zend OPcache API is restricted by "restrict_api" configuration directive in /htdocs/vendor/symfony/symfony/src/Symfony/Component/Debug/DebugClassLoader.php on line 144

Fatal error: Uncaught Symfony\Component\Debug\Exception\ContextErrorException: Warning: Zend OPcache API is restricted by "restrict_api" configuration directive in /htdocs/vendor/symfony/symfony/src/Symfony/Component/Debug/DebugClassLoader.php:144
Stack trace:
#0 [internal function]: Symfony\Component\Debug\DebugClassLoader->loadClass('Symfony\Bundle\...')
#1 /htdocs/bin/console(26): spl_autoload_call('Symfony\Bundle\...')
#2 {main}
thrown in /htdocs/vendor/symfony/symfony/src/Symfony/Component/Debug/DebugClassLoader.php on line 144
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the symfony-scripts event terminated with an exception

[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:
Warning: Zend OPcache API is restricted by "restrict_api" configuration directive in /htdocs/vendor/symfony/symfony/src/Symfony/Component/Debug/DebugClassLoader.php on line 144
Fatal error: Uncaught Symfony\Component\Debug\Exception\ContextErrorException: Warning: Zend OPcache API is restricted by "restrict_api" configuration directive in /htdocs/vendor/symfony/symfony/src/Symfony/Component/Debug/DebugClassLoader.php:144
Stack trace:
#0 [internal function]: Symfony\Component\Debug\DebugClassLoader->loadClass('Symfony\Bundle\...')
#1 /htdocs/bin/console(26): spl_autoload_call('Symfony\Bundle\...')
#2 {main}
thrown in /htdocs/vendor/symfony/symfony/src/Symfony/Component/Debug/DebugClassLoader.php on line 144 `

I think it's the best to oppress the throwing of the exception by oppressing the Exception with @.

E.g. $wasCached = \function_exists('opcache_is_script_cached') && @opcache_is_script_cached($file);

See wpsharks/comet-cache#733

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions