Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WP cron option to purge caches on schedule #971

Merged
merged 18 commits into from
Nov 6, 2024
Merged

WP cron option to purge caches on schedule #971

merged 18 commits into from
Nov 6, 2024

Conversation

jacobd91
Copy link
Contributor

@jacobd91 jacobd91 commented Oct 3, 2024

This PR simply adds a new option on the General settings page and on the advanced setting pages for Page, DB, Minify, and Object caches. This new option is it's own meta box containing an enable checkbox and a time and interval selector to define when the WP cron event should be run and on what interval. These cron events simply call a flush on the relevant cache

@jacobd91 jacobd91 self-assigned this Oct 3, 2024
@jacobd91 jacobd91 marked this pull request as draft October 3, 2024 17:10
@codecov-commenter
Copy link

codecov-commenter commented Oct 3, 2024

Codecov Report

Attention: Patch coverage is 0% with 640 lines in your changes missing coverage. Please review.

Project coverage is 0.89%. Comparing base (41ab929) to head (798cfd5).

Files with missing lines Patch % Lines
inc/options/dbcache.php 0.00% 67 Missing ⚠️
inc/options/minify.php 0.00% 67 Missing ⚠️
inc/options/objectcache.php 0.00% 67 Missing ⚠️
inc/options/pgcache.php 0.00% 67 Missing ⚠️
inc/options/general.php 0.00% 50 Missing ⚠️
PgCache_Environment.php 0.00% 35 Missing ⚠️
Minify_Environment.php 0.00% 32 Missing ⚠️
ObjectCache_Environment.php 0.00% 29 Missing ⚠️
DbCache_Environment.php 0.00% 26 Missing ⚠️
DbCache_Plugin_Admin.php 0.00% 22 Missing ⚠️
... and 12 more
Additional details and impacted files
@@             Coverage Diff             @@
##             master    #971      +/-   ##
===========================================
- Coverage      0.90%   0.89%   -0.01%     
- Complexity    19609   19697      +88     
===========================================
  Files           679     679              
  Lines         98868   99358     +490     
===========================================
  Hits            893     893              
- Misses        97975   98465     +490     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jacobd91 jacobd91 marked this pull request as ready for review October 24, 2024 18:05
@cssjoe cssjoe self-requested a review October 28, 2024 16:58
Copy link
Member

@cssjoe cssjoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Object Cache does not have disk option "file_generic".
  • WP Cron and the database use UTC/GMT, but the UI converts to the site/user locale timezone.

See comments.

ObjectCache_Environment.php Outdated Show resolved Hide resolved
ObjectCache_Plugin.php Outdated Show resolved Hide resolved
Util_Environment.php Outdated Show resolved Hide resolved
inc/options/minify.php Outdated Show resolved Hide resolved
inc/options/dbcache.php Outdated Show resolved Hide resolved
inc/options/general.php Outdated Show resolved Hide resolved
inc/options/objectcache.php Outdated Show resolved Hide resolved
inc/options/pgcache.php Outdated Show resolved Hide resolved
@jacobd91 jacobd91 requested a review from cssjoe November 4, 2024 17:43
Copy link
Member

@cssjoe cssjoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Users don't have an option to choose a timezone different from the WP site timezone, so there is no "timezone" in user meta. You can just set the variable to wp_timezone(). If it's only used once in a method, then use wp_timezone() there.

When I enable the feature and choose a time in the past, I don't see the WP Cron event scheduled if I choose anything other than "weekly".

Util_Environment.php Outdated Show resolved Hide resolved
Util_Environment.php Outdated Show resolved Hide resolved
inc/options/dbcache.php Outdated Show resolved Hide resolved
inc/options/dbcache.php Outdated Show resolved Hide resolved
inc/options/general.php Outdated Show resolved Hide resolved
inc/options/minify.php Outdated Show resolved Hide resolved
inc/options/objectcache.php Outdated Show resolved Hide resolved
inc/options/objectcache.php Outdated Show resolved Hide resolved
inc/options/pgcache.php Outdated Show resolved Hide resolved
inc/options/pgcache.php Outdated Show resolved Hide resolved
@jacobd91 jacobd91 requested a review from cssjoe November 4, 2024 21:13
@cssjoe cssjoe merged commit 1a16ec8 into master Nov 6, 2024
2 checks passed
@cssjoe cssjoe deleted the cron-flush branch November 6, 2024 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants