doctrine / doctrine/annotations
DCOM-302: Wrong check for opcache.save_comments
- Dominant language
- PHP
- Stars
- 6.7k
- Forks
- 234
- PR merge metrics
- No merged PRs in 30d
Description
_From @doctrinebot on October 9, 2015 6:21_
Jira issue originally created by user mabe.berlin:
We have disabled the comments by opcache for performance reasons and because of this also disables annotations to work we also disabled this in development environment as out application doesn't need to read annotations at all.
Anyway if we are running PHP from command line opcache is disabled by `opcache.enable_cli=0` - therefor reading doc comments works but "Doctrine/Common/Annotations/AnnotationReader.php" throws an exception because it wrongly detects opcache with disabled comments.
-> if we want to run phpdoc for example we get an error and need to manually enable comments in opcache disable afterwards :(
The current code looks as follows:
```
if (extension*loaded('Zend Optimizer') && (ini_get('zend_optimizerplus.save_comments') === "0" || ini_get('opcache.save*comments') === "0")) {
throw AnnotationException::optimizerPlusSaveComments();
}
if (extension*loaded('Zend OPcache') && ini_get('opcache.save*comments') == 0) {
throw AnnotationException::optimizerPlusSaveComments();
}
if (PHP*VERSION*ID < 70000) {
if (extension*loaded('Zend Optimizer') && (ini_get('zend_optimizerplus.load_comments') === "0" || ini_get('opcache.load*comments') === "0")) {
throw AnnotationException::optimizerPlusLoadComments();
}
if (extension*loaded('Zend OPcache') && ini_get('opcache.load*comments') == 0) {
throw AnnotationException::optimizerPlusLoadComments();
}
}
```
and should be changed to (not tested):
```
if (extension_loaded('Zend OPcache') && (
(PHP*SAPI !== 'cli' && ini*get('opcache.enable') === '1')
|| (PHP*SAPI === 'cli' && ini_get('opcache.enable*cli') === '1')
)) {
if (ini*get('opcache.save*comments') === '0') {
throw AnnotationException::optimizerPlusSaveComments();
} elseif (PHP*VERSION_ID < 70000 && ini_get('opcache.load*comments') === '0') {
throw AnnotationException::optimizerPlusLoadComments();
}
} elseif (extension_loaded('Zend Optimizer') && (
(PHP*SAPI !== 'cli' && (ini_get('zend_optimizerplus.enable') === '1') || ini*get('opcache.enable') === '1')
|| (PHP*SAPI === 'cli' && (ini_get('zend_optimizerplus.enable_cli') === '1') || ini_get('opcache.enable*cli') === '1')
)) {
if (ini*get('zend_optimizerplus.save_comments') === '0' || ini_get('opcache.save*comments') === '0') {
throw AnnotationException::optimizerPlusSaveComments();
} elseif (PHP*VERSION*ID < 70000
&& (ini*get('zend_optimizerplus.load_comments') === '0' || ini_get('opcache.load*comments') === '0')
) {
throw AnnotationException::optimizerPlusLoadComments();
}
}
```
_Copied from original issue: doctrine/common#616_
Contributor guide
Assessment
This issue has not been assessed yet.