From 231ea65f43eafe4f158a53cdb73b2cee44029a58 Mon Sep 17 00:00:00 2001 From: Gary Jones <gary.jones@automattic.com> Date: Wed, 26 Mar 2025 22:45:21 -0700 Subject: [PATCH] VIP-Go: change cron interval min value interval VIP's cron setup https://wpvip.com/blog/wordpress-cron/ https://docs.wpvip.com/wordpress-on-vip/cron-control/ Can handle frequent heavy cron schedules. Increase job frequency does not equate to slower site performance as the jobs are run async on dedicated batch containers, not front end requests. --- WordPress-VIP-Go/ruleset-test.inc | 10 ++++++++++ WordPress-VIP-Go/ruleset-test.php | 1 + WordPress-VIP-Go/ruleset.xml | 7 +++++++ 3 files changed, 18 insertions(+) diff --git a/WordPress-VIP-Go/ruleset-test.inc b/WordPress-VIP-Go/ruleset-test.inc index bd7e3de6..b0942dd7 100644 --- a/WordPress-VIP-Go/ruleset-test.inc +++ b/WordPress-VIP-Go/ruleset-test.inc @@ -577,3 +577,13 @@ $_SERVER["REMOTE_ADDR"]; // Error. // WordPress.CodeAnalysis.AssignmentInTernaryCondition $var = ($a = 123) ? $a : 0; // Warning. + +// WordPress.WP.CronInterval +function my_add_weekly( $schedules ) { + $schedules['every_30_seconds'] = array( + 'interval' => 30, + 'display' => __( 'Once every 30 seconds' ) + ); + return $schedules; +} +add_filter( 'cron_schedules', 'my_add_weekly'); // Warning. diff --git a/WordPress-VIP-Go/ruleset-test.php b/WordPress-VIP-Go/ruleset-test.php index d8701db4..51e19267 100644 --- a/WordPress-VIP-Go/ruleset-test.php +++ b/WordPress-VIP-Go/ruleset-test.php @@ -232,6 +232,7 @@ 550 => 1, 556 => 1, 579 => 1, + 589 => 1, ], 'messages' => [ 7 => [ diff --git a/WordPress-VIP-Go/ruleset.xml b/WordPress-VIP-Go/ruleset.xml index 35591e4a..887306be 100644 --- a/WordPress-VIP-Go/ruleset.xml +++ b/WordPress-VIP-Go/ruleset.xml @@ -232,6 +232,12 @@ <rule ref="WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn"> <severity>3</severity> </rule> + <rule ref="WordPress.WP.CronInterval"> + <!-- cron runs async on VIP's batch containers, so high frequency schedules will not negatively impact performance. Cron runner polling interval is 60s, so make that the min --> + <properties> + <property name="min_interval" value="60"/> + </properties> + </rule> <!-- Silence is golden, these don't affect us on VIP Go --> <rule ref="VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable"> @@ -254,4 +260,5 @@ <rule ref="WordPress.Security.EscapeOutput.ExceptionNotEscaped"> <severity>0</severity> </rule> + </ruleset>