Repository navigation
Cache API: Respect the expiration time in the default object cache. - #16447
divyesh-addweb wants to merge 2 commits into
Conversation
Keys stored with an expiration now expire during long-running requests. See #55847.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
@propsbot refresh |
Test ReportEnvironment: wordpress-develop Docker, PHP 8.3.35, default Steps: one
Tests: Works as described 👍 |
Trac ticket: https://core.trac.wordpress.org/ticket/55847
Problem
The default
WP_Object_Cacheignores the$expireargument. In long-running requests, such as cron jobs, a value remains readable after it should have expired.Solution
$expire > 0._exists()and remove them.delete(),flush(),flush_group()andreset().incr()anddecr()keep the existing expiration.time()is only called for keys that have an expiration. External object cache drop-ins replace this class, so they are not affected.Behavior changes
replace(),delete(),incr()anddecr()returnfalse, andadd()succeeds.Testing
Adds 5 tests to
tests/phpunit/tests/cache.php.--group cache: passes on single site and multisite, on trunk at fd51bac.falseafter it.Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5.5
Used for: Writing the patch, unit tests and running the tests.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.