pronamic / wp-pronamic-pay-woocommerce

WooCommerce driver for the WordPress payment processing library.

Home Page:http://www.wp-pay.org/extensions/woocommerce/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Upgrade 4.2.0 problem Action Scheduler

remcotolsma opened this issue · comments

Sorry for the late reply, Reüel. Just now deleted that record from the options table and refreshed the admin. Action is again added to schedule, but then fails again.
Pronamic Pay, Versie 9.5.1
WooCommerce, Versie 8.1.1

I’ve seen the failed status after the action having been executed via WP Cron, via WP CLI and via Admin List Table. Every time the reason is:

“Scheduled action for pronamic_pay_schedule_woocommerce_upgrade_4_2_0 will not be executed as no callbacks are registered.”

https://wordpress.org/support/topic/failed-action-scheduler-hook/#post-17122366

Could this have something to do with the following code:

/**
* Construct 4.2.0 upgrade.
*/
public function __construct() {
parent::__construct( '4.2.0' );
// Check for WooCommerce Subscriptions.
if ( ! function_exists( '\wcs_get_subscription' ) ) {
return;
}
\add_action( 'pronamic_pay_schedule_woocommerce_upgrade_4_2_0', [ $this, 'schedule_pages' ] );
\add_action( 'pronamic_pay_schedule_page_woocommerce_upgrade_4_2_0', [ $this, 'schedule_actions' ], 10, 1 );
\add_action( 'pronamic_pay_woocommerce_upgrade_4_2_0', [ $this, 'upgrade_subscription' ], 10, 1 );
}

If the wcs_get_subscription() function does not exists the action hooks are not added. But the upgrade execution function schedules the actions anyway?

/**
* Execute.
*
* @return void
*/
public function execute(): void {
// Schedule start action.
$this->schedule();
}

Also see core:
https://github.com/pronamic/wp-pay-core/blob/529e6f2568a3e2fd380b23a08e32cf4b22af42a0/src/Admin/Install.php#L66-L91

Good catch! Resolved in 9c32d16.