Repository navigation
fix: clear the snippet cache before new state is read back - #572
Merged
Merged
Conversation
…into fix/snippet-cache-invalidation-order/core # Conflicts: # CHANGELOG.md
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.
Fixes #561.
Every write in
snippet-ops.phpcleared the cached snippet list as its last step, after the new state had already been read back and handed to the write's hooks. Anything reading in between was served the snippet as it stood before the write.On a site with a persistent object cache this is visible to every user: saving an edited snippet returned the snippet as it was beforehand, and that value is what the REST update response is built from. Activating or deactivating reported the previous status. With file-based execution, the listener on each hook reads the snippet back, so a deactivated snippet was written to disk still marked active and went on running.
The cache is now cleared as soon as the database changes, before the snippet is read back and before any hook fires. Applied across
save_snippet(),activate_snippet(),activate_snippets(),deactivate_snippet(),delete_snippet(),trash_snippet()andrestore_snippet().deactivate_snippet()also now passes the network flag when reading the snippet back, which it previously left to default.Not covered here
The remaining part of the file-based execution report — no fallback to the database when the on-disk index is missing, and no rebuild outside of saving the settings page — is a separate change.
Verification
lint:phppass.