Conversation
OPcache served the old version of a script for up to 2 seconds after a change, so the page fetched by the hot reload client could be stale. The value is set through the SAPI INI defaults: php.ini files and php_ini directives still take precedence.
henderkes
reviewed
Oct 2, 2026
Comment on lines
+1490
to
+1500
| /* php.ini files and php_ini directives override these defaults. */ | ||
| static void frankenphp_ini_defaults(HashTable *configuration_hash) { | ||
| if (go_is_hot_reload_enabled()) { | ||
| /* Otherwise, a page reloaded right after a change may run the old code. */ | ||
| zval tmp; | ||
| ZVAL_NEW_STR(&tmp, zend_string_init("0", sizeof("0") - 1, 1)); | ||
| zend_hash_str_update(configuration_hash, "opcache.revalidate_freq", | ||
| sizeof("opcache.revalidate_freq") - 1, &tmp); | ||
| } | ||
| } | ||
|
|
Contributor
There was a problem hiding this comment.
I'm not a fan of this. Can we not just do this for tests?
Member
Author
There was a problem hiding this comment.
I'm not sure to follow. It's not to fix our tests but making hot reload reliable.
Contributor
There was a problem hiding this comment.
Oh, I thought this was only needed for tests. Have you benchmarked the impacts of this? Especially on Windows this could be a severe performance degradation.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With the default
opcache.revalidate_freq=2, OPcache keeps serving the old version of a changed script for up to 2 seconds. The hot reload client fetches the page right after the Mercure update, so it often receives stale HTML: the morph is a no-op, or the full reload displays the old content. In an end-to-end test with headless Chrome and frankenphp-hot-reload, every PHP change was missed with the default settings.When
hot_reloadis configured,opcache.revalidate_freqnow defaults to0. The value is set through theini_defaultsSAPI hook (the one the CLI SAPI uses fordisplay_errors), which runs before the INI files are parsed: a value set inphp.ini, in a file ofPHP_INI_SCAN_DIR, or with thephp_inidirective takes precedence.Worker mode with
watchisn't affected, as it reboots PHP on every change.