Uploaded image for project: 'Doctrine 2 - ORM'
  1. Doctrine 2 - ORM
  2. DDC-2388

Zend Optimizer Plus/opcache have overlap in config settings, annotations reader doesn't identify these properly


    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.3
    • Fix Version/s: 2.4
    • Component/s: Mapping Drivers
    • Labels:



      A change was recently authored in the AnnotationReader constructor that checked for a properly configured opcode cache (namely saving comments so that Doctrine can parse annotations).

      The current open source version of Zend Optimizer+ hosted at GitHub (https://github.com/zend-dev/ZendOptimizerPlus) when loaded registers itself as a module with the name "Zend Optimizer+" but takes configuration directives in the form of "opcache.<parameter>".

      The change to the constructor requires that if the module name is Zend Optimizer+, then the configuration directives must be prefixed with "zend_optimizerplus.<parameter>". This is clearly incorrect.

      The most recent update now complains of an AnnotationException as a consequence of this change when running Symfony2 (or Doctrine) with the latest opcache because configuration directives aren't detected properly.

      I am happy to fix this but could not find a way to report an issue to initiate the process.

      I would suggest something like this in the constructor:

      if ((extension_loaded('Zend Optimizer+') || extension_loaded('opcache')) && !(ini_get('opcache.save_comments') == 0 XOR ini_get('zend_optimizerplus.save_comments') == 0)) {

      What this means is that if either extension is loaded, one of those directives must be true and configured. This is a compromise. The alternative would be to keep the original source and do the following:

      if (extension_loaded('Zend Optimizer+') && ini_get('zend_optimizerplus.save_comments') == 0) {
      if (ini_get('opcache.save_comments') == 0)

      { throw AnnotationException::optimizerPlusSaveComments(); }


      if (extension_loaded('opcache') && ini_get('opcache.save_comments') == 0)

      { throw AnnotationException::optimizerPlusSaveComments(); }

      I have no idea about the "opcache" module and what it actually equates to or whether it has alternative formats for its configuration directives. I feel like the second suggestion is even smellier than my original suggestion despite probably handling the edge case better.

      If you want a pull request, I will send one, just let me know how you want to handle it.

      If my PHP is horrible I apologise.


        scribblet Ross Cousens created issue -
        beberlei Benjamin Eberlei made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        beberlei Benjamin Eberlei made changes -
        Fix Version/s 2.4 [ 10321 ]


          • Assignee:
            beberlei Benjamin Eberlei
            scribblet Ross Cousens
          • Votes:
            0 Vote for this issue
            3 Start watching this issue


            • Created: