0

wordpress it seem not reset opcache after plug-in/theme/core update.

For solve this issue i have set in the php.ini

opcache.validate_timestamps=1

all work correctly but validate_timestamps when it's enabled, PHP will check the file timestamp each request with a performance degradation. When it's disabled, PHP files are NEVER checked for updated code. When wordpress updating code, new code files can get mixed with old ones, the results are unknown. It's unsafe as hell.

Why wordpress not perform an opcache_reset() after each update?

alternatively... if I can call opcache_reset on action upgrader_process_complete, eg.:

if( extension_loaded('Zend OPcache') ){
    add_action('upgrader_process_complete', 'opcache_reset', 1000, 0);
}

it is correct?

  • please, this is a site aimed at questions related to software development, not bug reports. If you think wordpress should call that function, the proper place to raise that issue is on wordpress trac. – Mark Kaplun Apr 9 '16 at 8:21
  • @MarkKaplun ok, i have updated the question with a point on software development... – Simone Nigro Apr 9 '16 at 9:55
1

Several comments

  1. just in case, you probably should check that the PHP version is 5.5 and above before calling the function (or check for its existence, not sure if an equivalent function existed in the original APC under the same name)

  2. You priority is too high. You actually want to call it after all other plugins have finished whatever they are doing after an upgrade, just in case they do something that impacts any PHP files. Go for a priority of PHP_INT_MAX -1.

Your code might actually get triggered too many times if there are several upgrades done in the same time but except for slight performance hit I don't see anything bad that might come out of it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.