Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DCOM-302: Wrong check for opcache.save_comments #616

Closed
doctrinebot opened this issue Oct 9, 2015 · 1 comment
Closed

DCOM-302: Wrong check for opcache.save_comments #616

doctrinebot opened this issue Oct 9, 2015 · 1 comment
Assignees
Labels

Comments

@doctrinebot
Copy link

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</ins>') && (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<ins>') && (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</ins>') && (
            (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();
            }
        }
@guilhermeblanco
Copy link
Member

This issue was moved to doctrine/annotations#88

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants