Using shutdown action is too expensive.
Just measured how often is SELECT query (which takes 0.5 seconds) called:
2021-12-29 15:06:35
2021-12-29 15:06:35
2021-12-29 15:06:35
2021-12-29 15:06:35
2021-12-29 15:06:35
2021-12-29 15:06:35
2021-12-29 15:06:35
2021-12-29 15:06:35
2021-12-29 15:06:35
2021-12-29 15:06:35
2021-12-29 15:06:35
2021-12-29 15:06:35
2021-12-29 15:06:35
2021-12-29 15:06:35
2021-12-29 15:06:35
2021-12-29 15:09:36
2021-12-29 15:09:36
2021-12-29 15:09:36
2021-12-29 15:09:36
2021-12-29 15:09:36
2021-12-29 15:09:36
2021-12-29 15:09:36
2021-12-29 15:09:36
2021-12-29 15:09:37
2021-12-29 15:09:49
2021-12-29 15:09:51
2021-12-29 15:10:57
2021-12-29 15:13:57
2021-12-29 15:13:57
2021-12-29 15:13:57
2021-12-29 15:13:57
2021-12-29 15:13:57
2021-12-29 15:13:57
2021-12-29 15:13:57
2021-12-29 15:13:57
2021-12-29 15:13:57
Maybe we should add an option to trigger this as a cron job instead of using shutdown action?
]]>The SELECT query should include post_date <= NOW()
clause to limit results to missed scheduled posts only, not all future posts.
This makes STRETCH unnecessary.
Or if you insist on STRETCH functionality, we should add post_date
field to SELECT and compare to current time in foreach ($scheduled_posts as $post_id)
loop, to prevent fetching all future posts which check_and_publish_future_post
does.
Hello,
Thank you for the plugin. I used it for a year but recently, I notice the following error message in the error log:
[162.158.151.247:34320] [STDERR] PHP Fatal error: Uncaught Error: Call to undefined function get_current_screen() in /public_html/wp-content/plugins/scheduled-post-guardian/scheduled-post-guardian.php:89
Stack trace:
#0 /public_html/wp-includes/plugin.php(235): Scheduled_Post_Guardian_Plugin->run_on_edit_dot_php(false)
#1 /public_html/wp-content/plugins/scheduled-post-guardian/scheduled-post-guardian.php(59): apply_filters(‘scheduled_post_…’, false)
#2 /public_html/wp-includes/plugin.php(524): Scheduled_Post_Guardian_Plugin->shutdown(”)
#3 /public_html/wp-includes/load.php(671): do_action(‘shutdown’)
#4 [internal function]: shutdown_action_hook()
#5 {main}
thrown in //public_html/wp-content/plugins/scheduled-post-guardian/scheduled-post-guardian.php on line 89
I use PHP7.0. Could you please take a look?
Thank you.
]]>