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 schedule not sending mail #3

Open
openmindculture opened this issue Oct 4, 2023 · 16 comments
Open

WP cron schedule not sending mail #3

openmindculture opened this issue Oct 4, 2023 · 16 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@openmindculture
Copy link
Owner

Mail function works when called from an admin page, but does not seem to work inside a cron schedule callback.

  • verify permissions

Maybe it does and it's a permission issue that we don't get any inbox entries?

  • verify that the cron is executed

Always send a mail, with or without a report.

Set schedule interval to hourly for testing purposes.

@openmindculture openmindculture added the bug Something isn't working label Oct 4, 2023
@openmindculture openmindculture self-assigned this Oct 4, 2023
@openmindculture
Copy link
Owner Author

@openmindculture
Copy link
Owner Author

openmindculture commented Oct 9, 2023

Tried various things

  • installed the WP Crontrol plugin to verify cron setup -> detected and fixed 1 mistake
  • added try/catch blocks
  • added mail sending trigger after plugin page preview
  • added fallback messages if the report is empty
  • tried alternative data source using wpdb
  • updated the blog post
  • updated this issue
  • added the "help wanted" label.

It seems that the cron schedule callback is not executed when called by cron,
but if it was, it would not have sufficient permissions to generate a report.

@openmindculture openmindculture added the help wanted Extra attention is needed label Oct 9, 2023
@openmindculture
Copy link
Owner Author

openmindculture commented Oct 11, 2023

Got some erractic inbox mails obviously sent via scheduled callback about 2 days after setting hourly schedule!
New hypothesis: maybe a caching issue?

Cron scheduled as hourly: 20231009
Cron mail received: 20231011-19:11
Cron mail received: 20231011-19:52

Caching disabled: 20231011-20:41

Cron mail received: 20231011-20:50
Cron mail received: 20231011-21:50

Caching reenabled with page cache only: 20231011-21:56

W3 Total Cache Configuration before deactivation:

  • Page Cache: Enable
  • Page Cache method: Disk: enhanced
  • Minify: enable
  • Opcode Cache: Zend Opcache
  • Object Cache: Enable
  • Object Cache Method: Disk
  • Browser Cache: Enable

Not enabled: Database Cache, CDN, Reverse Proxy, Fragment Cache, Miscellaneous, Debug

@openmindculture
Copy link
Owner Author

Follow-up: watch inbox after reenabling, verify with different caching options, await support:
https://wordpress.org/support/topic/wp-cron-callbacks-not-executed/

@openmindculture
Copy link
Owner Author

No more scheduled mails after reactivating page cache.

@openmindculture
Copy link
Owner Author

Caching changed: 20231012-1944 Page cache disabled, frontend minify disabled, object cache stays enabled, browser cache stays enabled

@openmindculture
Copy link
Owner Author

openmindculture commented Oct 15, 2023

WordPress core update to 6.3.2 on Friday 20231013
Unchanged settings,
Scheduled callback triggered mails
20131015-0350
20131015-0451
20131015-0550
20131015-0650
20131015-0850
20131015-1051
20131015-1150

@openmindculture
Copy link
Owner Author

received mails hourly, switch to twice daily

@openmindculture
Copy link
Owner Author

openmindculture commented Oct 17, 2023

reenabled W3TC page cache,
set interval to hourly

Oct 16, 2023, 11:24
Can’t reproduce the issue anymore. About 1 day after WordPress core update to 6.3.2 cron suddenly worked as expected without any settings changed.

I will reenable page cache now and see if it occurs again.

Oct 18:
No more cron since I activated page cache.

@openmindculture
Copy link
Owner Author

The situation is getting even more erratic.
I didn't touch any settings and didn't explicitly clear the cache; WP core and W3TC is still the same since my last comment. But since tonight 3:05 a.m. I receive scheduled report mails again. Despite the expected hourly schedule, probably due to low traffic page visitors, these are the successful callback times so far:
02:53
03:05
04:12
04:16
05:04
05:19
05:53
06:06
06:55
07:05
07:50
08:07
08:56
09:06
09:55
09:56
10:02
10:04

@openmindculture
Copy link
Owner Author

I have installed the same plugin on another site which also uses W3 TC page cache now.

@openmindculture
Copy link
Owner Author

After talking to myself in support issues, like I often do, while nobody seems to be able to help, I will test alternative solutions:

  • switch caching plugins to verify if it is W3TC related or if the same problems occurs with WP Rocket or other alternatives,
  • use an alternative to WP_Cron which seems like an unrealiable hack anyway.

@openmindculture
Copy link
Owner Author

openmindculture commented Oct 30, 2023

Manual call of the wp-cron.php URL does not trigger sending a mail either:

Disable W3TC.
(Possibly install WP Super Cache ...

Try above wp-cron call... does not work either!

Try the logged in plugin page:
https://www.open-mind-culture.org/wp-admin/admin.php?page=contact-form-inbox-report-mailer

No mail either. So that's the problem after the latest update?

@openmindculture
Copy link
Owner Author

More debug info, installed and rescheduled, send on view admin page works again, at least sometimes, erratically, unless wp_mail returns false. Live testing since Monday noon, 30. October 2023:

  • KleiderOrdnung with W3TC
  • Open-Mind-Culture without caching

@openmindculture
Copy link
Owner Author

Current status:

  • test page sends mail (using openmindculture_cfirm_schedule) most of the times
  • sometimes wp_mail returns false for no obvious reason
  • openmindculture_cfirm_schedule, invoked once using WP Crontrol, does not succeed in sending mail
  • hourly schedule never suceedds in sending mail

@openmindculture
Copy link
Owner Author

Warning (found on the UpdraftPlus backup page, K.O. page):

Warnung: WordPress has a number (5) of scheduled tasks which are overdue. Unless this is a development site, this means that the scheduler in your WordPress install is not working properly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant