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

[Super Cache] Ensure cron schedule is setup whenever the config changes #28545

Merged
merged 3 commits into from
Jan 24, 2023

Conversation

thingalon
Copy link
Member

Possibly related: https://wordpress.org/support/topic/empty-cache-directories/

When you set a preload schedule in wp-super-cache, the cron job was only being set up if one was already scheduled. If one wasn't for any reason, then it did not add one.

This PR changes the way that cronjobs are managed: Any time the settings are edited, it ensures that there is a cron if one should be there, and there isn't one if not. If the interval gets edited, then the cronjob gets destroyed (if it exists) and recreated.

Note: this will not schedule a cronjob if preload mode is not enabled. I wanted to verify with @donnchawp that's the correct / expected behaviour.

Proposed changes:

  • Ensure that preload crons are scheduled (or cancelled) on settings edit

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

n/a

Does this pull request change what data or activity we track or use?

no

Testing instructions:

  • Try turning on preload mode, ensure a cron is appropriately scheduled
  • Turn off preload mode, make sure there is no cron
  • Turn on preload mode and edit the interval, ensure the correct interval gets set.

@thingalon thingalon added this to the super-cache/1.9.3 milestone Jan 24, 2023
@thingalon thingalon requested review from donnchawp and a team January 24, 2023 05:59
@thingalon thingalon self-assigned this Jan 24, 2023
@github-actions github-actions bot added the [Plugin] Super Cache A fast caching plugin for WordPress. label Jan 24, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jan 24, 2023

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Super Cache plugin:

  • Next scheduled release: February 7, 2023.
  • Scheduled code freeze: January 30, 2023.

Copy link
Member

@dilirity dilirity left a comment

Choose a reason for hiding this comment

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

:shipit:

Thank you for this! I remember a while back I was testing preload for a support ticket and I couldn't re-schedule a preload after deleting it with WP Crontrol or something.

This update makes things work as expected.

@thingalon thingalon merged commit 0ab4cdd into trunk Jan 24, 2023
@thingalon thingalon deleted the super-cache/fix-schedule branch January 24, 2023 22:44
thingalon added a commit that referenced this pull request Jan 30, 2023
…he config changes (#28545)

* Fix scheduling events when none already scheduled

* changelog

* Refactor: declarative approach over event-driven approach

Co-authored-by: Mark George <thingalon@gmail.com>
@thingalon
Copy link
Member Author

Cherry-picked into 1.9.3 via 9d599e0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Super Cache A fast caching plugin for WordPress.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants