Make WordPress Core

Opened 20 months ago

Last modified 18 months ago

#57159 new enhancement

Add scheduled events in the site health report.

Reported by: sebastienserre's profile sebastienserre Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Site Health Keywords: 2nd-opinion needs-patch
Focuses: Cc:

Description

Hello,

Do you think it should be possible to have a list of scheduled events in the Site Health report ?

Having this information may help to debug some "strange" behaviour.

Thank you

Change History (7)

#1 @johnbillion
20 months ago

  • Type changed from defect (bug) to enhancement

Bear in mind that if the site is having problems with cron events, this list can potentially contain thousands of cron event entries. This is why plugins such as WP Crontrol and Advanced Cron Manager use pagination on the cron event listing screens.

What sort of "strange" behaviour relating to cron do you think could be surfaced in site health?

#2 @sebastienserre
20 months ago

Hello @johnbillion,

You're right, and I'm currently using WP Crontrol when needed.

I'm working on a plugin helpdesk and sometimes customers tells us that URLs randomly gone to 404 errors, and they need to refresh permalink.
The random action makes me think something maybe in scheduled action is doing something wrong.

That's why I was wondering if something could be done, thanks to the great site health feature.

#3 @rawrly
18 months ago

Hello johnbillion and sebastionserre.

I found this ticket when investigating a WP-Cron concern cited by CVE-2023-22622 and believe there is one solution for both this CVE and the problem you are concerned about sebastienserre. If WP-Crons are broken, or not running on a timely schedule it can cause hard to track issues or other problems in the Application.

One of the more serious examples would be the auto-update functionality, which relies on WP-Cron to complete.

CVE-2023-22622 describes a concern that if WP-Cron is failing or running sporadically, users should be made aware (so they can take action) instead of silently failing. To address this, WordPress can add a notification if WP-Cron tasks can be detected as not running.

Would it solve your concerns sebastienserre? If wp-admin had a notification that WP-Cron tasks were running off schedule, or not at all? This is different than your original request, but may fulfill it just the same. As johnbillion mentioned, there are plugins available for improved management of WP-Cron tasks.

---

The detection of WP-Cron issues can be done using WP-Cron itself, creating a WP-cron "heartbeat" task that logs it's last run time and alerts the administrator if it identifies the WP-Cron task itself runs too infrequently.

This will detect WP-Cron runs intermittently, but since it relies on WP-Cron it will not function if WP-Cron is disabled.

There needs to be at least one mechanism outside of WP-Cron that checks the WP-Cron queue for issues such as scheduling delays. If this mechanism is part of wp-admin, perhaps displayed in the dashboard (to be more prominent that site health) it would alert users WP-Cron is failing to run and direct them to proper support documentation. (This support documentation may need to be found or written)

---

I am looking forward to hearing your thoughts and ideas for this matter. Thank you.

Last edited 18 months ago by rawrly (previous) (diff)

#4 follow-up: @sebastienserre
18 months ago

Hello @rawrly,
My initial goals was to add in the site health any info about a missing schedule because it can help to debug or to find a start of debug.
In case of Cron, we could see that a task has been missed and then use different available tool to solve it.
Regards

#5 in reply to: ↑ 4 @rawrly
18 months ago

I did a little digging, discussion (pinging @Clorith to bring him into the conversation), and testing. It appears there is a notification within Site Health that informs users when scheduled tasks fail to run.

https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/class-wp-site-health.php#L1787

I tested this on my site and confirmed it works as expected, warning me that a "scheduled event has failed" with the name of the most recent WP-Cron task that failed to run. Would it help your concern if this warning are made more prominent or changed?

I have the following ideas that may help:

  1. The site health warning for failed to run scheduled tasks should make clear it is related to WP-Cron tasks, with a link to appropriate documentation to help the user address the problem. (documentation will needed to be written for this)
  2. The site health warning currently only lists the most recent failed task, it would be helpful to provide a number of failed tasks (WP-Crons) or provide an expandable list of failed tasks.
  3. It is true that not all WP-Cron tasks are equally important, some tasks failing to run (such as auto-updates or tasks introduced by plugins) shold be marked as "critical issues" instead of "recommended improvements". (someone would need to make a list of security related Wp-Cron default task names, and allow plugin devleopers to add their own task names to this list)

Is this in line with your goals?

#6 @sebastienserre
18 months ago

Yes @rawrly, it would be very useful

#7 @rawrly
18 months ago

  • Keywords needs-patch added
Note: See TracTickets for help on using tickets.