Fix default 'before' date in WP-CLI clean command #1343#1346
Open
MagicGeny wants to merge 1 commit into
Open
Conversation
Author
|
Hi @barryhughes! I wanted to provide some context for this PR. This change resolves the default 'before' value issue for the cleanup process. It is also a crucial dependency for another bugfix I just submitted in #13480 (which addresses the incorrect 'before' filtering in the WP-CLI clean command, #1107). I have tested this locally, and all tests pass. Please let me know if you would like me to adjust anything here so we can move this forward. Thank you! |
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.
Description
Closes #1343
This PR fixes an issue where running the
wp action-scheduler cleancommand without specifying the--beforeflag incorrectly deletes all completed/failed/cancelled actions instead of keeping the last 31 days of data as stated in the documentation.Cause of the bug
In
ActionScheduler_WPCLI_Clean_Command::clean(), the default value for thebeforeargument was set to an empty string''. When passed further down intostrtotime(), this empty string evaluates to "now", causing the cleaner to wipe out even newly created/completed actions.Solution
Changed the default value from
''to'31 days ago'to align the default CLI behavior with the plugin's default retention period and documentation.How to test
wp eval 'for($i=0; $i<5; $i++) { $id = as_schedule_single_action(time(), "test", [], "test"); ActionScheduler::store()->mark_complete($id); }'wp action-scheduler clean5 actions deleted.).0 batches processed.).