php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79005 validate_timestamps only has an effect when compiling the script
Submitted: 2019-12-20 08:59 UTC Modified: 2020-02-12 06:44 UTC
From: iquito at gmx dot net Assigned:
Status: Open Package: opcache
PHP Version: 7.4.2 OS: Debian Buster
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: iquito at gmx dot net
New email:
PHP Version: OS:

 

 [2019-12-20 08:59 UTC] iquito at gmx dot net
Description:
------------
When using php-fpm with opcache.validate_timestamps turned on and opcache.enable_file_override turned on, no script is ever reloaded in PHP 7.4.1 (it works as expected in 7.3.*). I am using the following options:

opcache.enable = 1
opcache.enable_cli = 0
opcache.validate_timestamps = 1
opcache.revalidate_freq = 0
opcache.use_cwd = 1
opcache.enable_file_override = 1

As soon as I set opcache.enable_file_override to 0, then validate_timestamps works again and changes to scripts are used by php-fpm. It does not matter what kind of script you are using - in my example, I used the following:

<?
//echo 'dada';
phpinfo();

And then I just changed the comment to the line with phpinfo, so the page should show "dada", but that does not happen.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-02-11 06:49 UTC] iquito at gmx dot net
-Summary: opcache validate_timestamps does not work with enable_file_override +Summary: php_admin_value unexpected behavior for php-fpm with validate_timestamps -PHP Version: 7.4.1 +PHP Version: 7.4.2
 [2020-02-11 06:49 UTC] iquito at gmx dot net
After more trials and tribulations validate_timestamps for opcache did not work at all anymore for me anymore. I have a php.ini with "opcache.validate_timestamps = 0" and overwrote that value for a testing pool in php-fpm with:

php_admin_value[opcache.validate_timestamps] = 1

When I check phpinfo() it says that opcache.validate_timestamps is "On", but no script is ever reloaded when it has changed.

When I set "opcache.validate_timestamps = 1" in php.ini and change it via "php_admin_value[opcache.validate_timestamps] = 0" for a php-fpm pool it seems to work as expected both for the pools which "unset" validate_timestamps and for those that do validate the timestamps.
 [2020-02-12 06:44 UTC] iquito at gmx dot net
-Summary: php_admin_value unexpected behavior for php-fpm with validate_timestamps +Summary: validate_timestamps only has an effect when compiling the script
 [2020-02-12 06:44 UTC] iquito at gmx dot net
After validate_timestamps stopped working again I think I found the true cause. When storing a script in opcache, it sets a "timestamp" of the script in opcache. If validate_timestamps is turned off at the time of compiling the script for opcache, then that timestamp is set to zero, and the script is never checked thereafter. If validate_timestamps is turned on when compiling the script, a "timestamp" is set in the opcache data (with the last modification date of the file), and the script will be checked every time it is loaded, even if validate_timestamps is set to on after that.

This was not that way until PHP 7.4 - basically, the validate_timestamps option seems to only have an effect at the time of compiling a script, after that opcache decides itself what and how it will check the file according to the value in "timestamp". I am not sure why the change in PHP 7.4, or if this is just simply a bug. When using different pools where some are with validate_timestamps and some are without, this creates some weird issues - especially when using opcache_compile_file to pre-cache files, which can then lead to all those files always validating timestamps or never validating timestamps, no matter what pool with what validate_timestamps setting is used.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Nov 23 17:01:23 2020 UTC