Repository navigation
Conversation
`WP_CLI::get_cache()` read both limits with `(int) $value ?: default`, so `WP_CLI_CACHE_EXPIRY=0` and `WP_CLI_CACHE_MAX_SIZE=0` became the 180-day and 300 MB defaults, although `FileCache` treats 0 as no limit. The default is now used only when the value casts to 0 and is not a number, so a number that casts to 0, such as `0` or `0.5`, turns the limit off. Empty and non-numeric values keep the defaults, and values that cast to a non-zero number are read as before.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Fixes #6452
WP_CLI::get_cache()read both cache limits with(int) $value ?: default, soWP_CLI_CACHE_EXPIRY=0andWP_CLI_CACHE_MAX_SIZE=0became the 180-day and 300 MB defaults.FileCachetreats 0 as no limit, and a negative value already turned a limit off, so 0 was the one value that could not.The default is now used only when the value casts to 0 and is not a number. So a number that casts to 0, such as
0or0.5, turns the limit off. Empty and non-numeric values keep the defaults, and values that cast to a non-zero number are read as before. Values set underenv:inwp-cli.ymlare covered too, since they are read through the sameget_env_or_config().Testing
features/cli-cache.featurereads the limits the cache is built with, for unset, empty,0,7200/1048576,-1andabc. A second outline makes a cached file 200 days old, forces the cleanup, and checks thatWP_CLI_CACHE_EXPIRY=0keeps it while the default removes it. The two0cases fail onmainand pass with the fix. The other cases pass on both.features/cli-cache.featureand the three cache scenarios infeatures/config.featurepass.phpcsis clean on the changed file.WP_CLI_CACHE_EXPIRY=0keeps a 200-day-old file andWP_CLI_CACHE_MAX_SIZE=0keeps a 301 MB file, set either way (environment orwp-cli.yml). Before the fix both files were removed. An empty value andabcstill use the defaults.Use of AI
AI assistance: Yes
Tool(s): Claude Code and Codex
Used for: tracing the bug, writing the tests, drafting the change, and reviewing it. I reviewed the reasoning and test results, and I take responsibility for the contribution.
Summary by CodeRabbit
0and-1.0keeps them from expiring.