Repository navigation
Fix "Next Run" showing 1970 for unscheduled jobs on non-UTC sites - #242
gunjanjaswal wants to merge 1 commit into
Conversation
On the Jobs list, the WP-Cron next-run cell added the site's gmt_offset to
wp_next_scheduled() before testing the result:
$nextrun = wp_next_scheduled( ... ) + ( get_option( 'gmt_offset' ) * 3600 );
if ( $nextrun ) { ...show date... } else { 'Not scheduled!' }
When a job has no scheduled event, wp_next_scheduled() returns false. In the
arithmetic PHP coerces false to 0, so on any site whose gmt_offset isn't 0 the
value becomes offset*3600 -- a small non-zero number that passes the if and
renders as 1970-01-01 (or 1969-12-31 for negative offsets) instead of
"Not scheduled!". It only looked correct in the UTC (offset 0) case.
Check wp_next_scheduled() for false first, and add the offset only once there's
a real timestamp. Scheduled jobs render exactly as before.
Fixes wp-media#144.
|
Gentle bump. This fixes the "Next Run" column showing 1970 for unscheduled jobs on non-English locales, a small scoped change, still mergeable. Happy to rebase if it's drifted; just flagging it's ready for review whenever someone has a moment. |
|
Gentle nudge here. The Jobs list adds the site's |
|
Gentle nudge here, this has been open a couple of months without a look. It's a small fix for the "Next Run" column showing year 1970 on unscheduled jobs on non-UTC sites (the gmt_offset was being added before the scheduled-or-not check). Still merges clean. Anything I can do to help get it reviewed? |
|
Checking back on this one. It's a contained fix for the "Next Run" column showing 1970 on unscheduled jobs, and it's still clean against the current branch. Happy to adjust if a maintainer wants anything changed, otherwise it's ready whenever someone has a moment to look. |
|
Circling back on this one. It's been open a good while, so no hard feelings if it isn't a priority. It's a small fix for the "Next Run" showing 1970 on non-UTC sites. I'm glad to rebase or tweak it if that helps, or to close it if it's not something you'd want to take. |
Fixes #144 (the "next backup scheduled for year 1970" part).
The bug
On the Jobs list, the WP-Cron "Next Run" cell adds the site's
gmt_offsettowp_next_scheduled()before checking whether anything is actually scheduled:When a job has no scheduled event,
wp_next_scheduled()returnsfalse. In the arithmetic PHP coercesfalseto0, so the value becomesoffset * 3600. On any site whose timezone offset isn't zero that's a small non-zero number, so theif ( $nextrun )passes and the cell renders 1970-01-01 (or 1969-12-31 for negative offsets) instead of "Not scheduled!". It only looks right in the UTC (offset 0) case, which is why it slips through.That's the "next backup gets scheduled for year 1970" the report describes — it's the display, not the schedule itself.
The fix
Check
wp_next_scheduled()forfalsefirst, and only add the offset once there's a real timestamp:Scheduled jobs render exactly as before; unscheduled ones now correctly say "Not scheduled!" on every timezone.
Verification
Reproducing the exact expression against a
falsereturn across a range of offsets:Note on the other half of the report
The issue also mentions scheduled jobs only running while an admin is logged in. That part is standard WP-Cron behavior — WP-Cron fires on site traffic, so a low-traffic site can miss runs until the next visit. The usual remedy is a real server cron hitting
wp-cron.php(orALTERNATE_WP_CRON), and it's separate from this display fix, so I've left it out of scope here. Happy to look at it separately if you'd like.