Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-48249

PHP opcache_reset() in CLI causes test fails

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Won't Do
    • 2.6.6, 2.7.3, 2.8, 2.9
    • None
    • Caching, Unit tests
    • MOODLE_26_STABLE, MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE

    Description

      I believe this to be a bug in php, but I'm opening an issue here to discuss it.

      I have the following settings in my php.ini for opcache:

      opcache.enable=1
      opcache.enable_cli=1
      

      Confirm that Opcache is running, then run:

      vendor/bin/phpunit --stop-on-failure core_cache_config_writer_testcase cache/tests/config_writer_test.php
      

      Now comment out the call to opcache_reset in lib/classes/string_manager_standard.php and re-run.

      I'm struggling to replicate this exactly as it outside of Moodle, however it appears that something is amiss with upstream php's opcache.

      Calling opcache_reset() causes subsequent calls to opcache_invalidate() to fail. The documentation for invalidate suggests that it will only return false if opcache is disabled, otherwise it returns true. The attached testcase.php suggests otherwise. This calls opcache_invalidate() on a real file both before and after a call to opcache_reset(). After the first call to opcache_reset(), all subsequent calls to opcache_reset() and opcache_validate() return false.

      This could be a bug in php, or it could be a php documentation issue. Either way, we may need to work around it in Moodle.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              dobedobedoh Andrew Lyons
              Matteo Scaramuccia, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: