Skip to content

Commit 4803823

Browse files
committed
Remove disabled cron at init time
1 parent 8fd3a40 commit 4803823

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

packages/runtime-cloudflare/src/worker.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,13 @@ function materializeCanonicalCronAdapter(php: PHP): void {
10721072
*/
10731073
10741074
if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) {
1075-
remove_action( 'init', 'wp_cron' );
1075+
add_action(
1076+
'init',
1077+
static function (): void {
1078+
remove_action( 'init', 'wp_cron' );
1079+
},
1080+
PHP_INT_MIN
1081+
);
10761082
}
10771083
`))
10781084
}

tests/cloudflare-runtime.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ test("Cloudflare canonical runtime materializes a conditional cron policy withou
320320
assert.ok(adapter, "The canonical cron policy materializer is present.")
321321
assert.match(adapter, /wp-content\/mu-plugins\/wp-codebox-canonical-cron-policy\.php/)
322322
assert.match(adapter, /defined\( 'DISABLE_WP_CRON' \) && DISABLE_WP_CRON/)
323-
assert.match(adapter, /remove_action\( 'init', 'wp_cron' \)/)
323+
assert.match(adapter, /add_action\([\s\S]*'init'[\s\S]*remove_action\( 'init', 'wp_cron' \)[\s\S]*PHP_INT_MIN/)
324324
assert.doesNotMatch(adapter, /wp_schedule_update_checks|wp_schedule_delete_old_privacy_export_files|\$GLOBALS\['wp_filter'\]/)
325325
assert.match(worker, /runtimeBucket\?: R2Bucket,\n canonicalCronAdapter = false,/)
326326
assert.match(worker, /authConstants, bucket, true\), pointer/)

0 commit comments

Comments
 (0)