is_cron_disabled doesn’t make sense
-
Hi there! I just noticed one of my sites getting really slow when performing some simple tasks (
wp_delete_post
for example).Turns out it was very slow db queries to the sg-security logs table. Here is an example:
INSERT INTO
wp_sgs_log_events
(visitor_id
,ts
,activity
,description
,ip
,hostname
,code
,object_id
,type
,action
,visitor_type
) VALUES (2, 1679387722, 'Deleted Post', 'Deleted Post - Benchmark for wp_delete_post #1', '127.0.0.1', 'localhost', 200, 'wpcli', 'post', 'delete', 'user')That table was huge in my case. After digging through the code, I noticed this function:
/** * Check if wp cron is disabled and send error message. * * @since 1.0.0 */ public static function is_cron_disabled() { if ( defined( 'DISABLE_WP_CRON' ) && true == DISABLE_WP_CRON ) { return 1; } return 0; }
…and this one:
/** * Set the cron job for deleting old logs. * * @since 1.0.0 */ public function set_sgs_logs_cron() { // Bail if cron is disabled. if ( 1 === Helper_Service::is_cron_disabled() ) { return; } if ( ! wp_next_scheduled( 'siteground_security_clear_logs_cron' ) ) { wp_schedule_event( time(), 'daily', 'siteground_security_clear_logs_cron' ); } }
The problem with this is, that the constant
DISABLE_WP_CRON
is only there to disable the WordPress fake cron. On my site I have a real cron job running. Soset_sgs_logs_cron
should actually always schedule the cleanup job, even ifDISABLE_WP_CRON
was set tofalse
.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘is_cron_disabled doesn’t make sense’ is closed to new replies.