Skip to content

Commit 45db170

Browse files
Fix fatal error when hidden Blocks input added from CRON (#5223) (#5228)
Patch to fix fatal error that occurs when a scheduled action calls `the_content` filter, creating a fatal error, because this inserted Blocks hidden input relies on absent WC session data. Co-authored-by: Samir Merchant <[email protected]>
1 parent 9cca596 commit 45db170

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: fix
3+
Comment: Minor patch fix to cron functionality that does not appear to have front-end ramifications for customers.
4+
5+

includes/class-wc-payments-blocks-payment-method.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,13 @@ public function get_payment_method_data() {
114114
* @return string
115115
*/
116116
public function maybe_add_card_testing_token( $content ) {
117+
if ( ! wp_script_is( 'WCPAY_BLOCKS_CHECKOUT' ) ) {
118+
return $content;
119+
}
120+
117121
$fraud_prevention_service = Fraud_Prevention_Service::get_instance();
118122
// phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.ValidatedSanitizedInput.MissingUnslash,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
119-
if ( $fraud_prevention_service->is_enabled() && wp_script_is( 'WCPAY_BLOCKS_CHECKOUT' ) ) {
123+
if ( $fraud_prevention_service->is_enabled() ) {
120124
$content .= '<input type="hidden" name="wcpay-fraud-prevention-token" id="wcpay-fraud-prevention-token" value="' . esc_attr( Fraud_Prevention_Service::get_instance()->get_token() ) . '">';
121125
}
122126
return $content;

0 commit comments

Comments
 (0)