Merge pull request #3245 from woocommerce/PCP-4350-a-s-pre-execution-callback-can-result-in-fatal-error-subscriptions

Remove `action_scheduler_before_execute` code (4350)
This commit is contained in:
Emili Castells 2025-03-25 16:28:33 +01:00 committed by GitHub
commit 39c8cc88b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -645,35 +645,6 @@ class PayPalSubscriptionsModule implements ServiceModule, ExtendingModule, Execu
2
);
add_action(
'action_scheduler_before_execute',
/**
* Param types removed to avoid third-party issues.
*
* @psalm-suppress MissingClosureParamType
*/
function( $action_id ) {
/**
* Class exist in WooCommerce.
*
* @psalm-suppress UndefinedClass
*/
$store = ActionScheduler_Store::instance();
$action = $store->fetch_action( $action_id );
$subscription_id = $action->get_args()['subscription_id'] ?? null;
if ( $subscription_id ) {
$subscription = wcs_get_subscription( $subscription_id );
if ( is_a( $subscription, WC_Subscription::class ) ) {
$paypal_subscription_id = $subscription->get_meta( 'ppcp_subscription' ) ?? '';
if ( $paypal_subscription_id ) {
as_unschedule_action( $action->get_hook(), $action->get_args() );
}
}
}
}
);
return true;
}