Woocommerce: Duplicate webhooks

Created on 30 Nov 2018  路  1Comment  路  Source: woocommerce/woocommerce

Describe the bug

With WooCommerce prior to 3.5.0, a webhook with the same $args would not be scheduled to run within 10 minutes of another. This is a result of how the wp_schedule_single_event() WP Cron API works, as explained in the codex entry:

Note that scheduling an event to occur before 10 minutes after an existing event of the same name will be ignored, unless you pass unique values for $args to each scheduled event. See wp_next_scheduled() for more information.

However, when WooCommerce moved to use Action Scheduler, no such restriction was enforced. Action Scheduler & WC()->queue() will add anything requested to the queue.

This leads to potentially _a lot_ of duplicate scheduled actions for webhooks, which causes two problems:

  1. it unnecessarily uses up rows in the posts table, which is what would be leading to reports like #21877
  2. it takes longer to process unique actions/jobs in the queue

I've seen at least one plugin leading to this issue, but I suspect there will be many more. Any plugin using order.updated webhooks is likely going to be creating the issue.

Expected behavior

To maintain backward compatibility and improve performance, I think it will be better to only schedule one of each webhook every 10 minutes.

Pull request incoming.

bug

Most helpful comment

Just adding a note here. This is a pretty significant issue for any store utilising webhooks, effectively breaking renewals for the site, and would definitely support a release as soon as possible.

>All comments

Just adding a note here. This is a pretty significant issue for any store utilising webhooks, effectively breaking renewals for the site, and would definitely support a release as soon as possible.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pawelkmpt picture pawelkmpt  路  3Comments

jameskoster picture jameskoster  路  3Comments

atimmer picture atimmer  路  3Comments

starypop picture starypop  路  3Comments

svenauhagen picture svenauhagen  路  3Comments