Commit Graph

42 Commits

Author SHA1 Message Date
Christopher Allford 7331036d17 Moved synchronous webhook execution into a shutdown function
One of the problems with synchronous webhooks is that they are executed as soon as the related action is. Since we may call an action multiple times in the process of updating something, this causes only the first action to trigger the hook. This differs from asynchronous execution because in that case, the web hook will be executed after the entire request has completed.
2020-06-25 16:54:17 -07:00
Mike Jolley dc883012b8 Missed null check in wc_load_webhooks 2019-02-18 16:58:16 +00:00
Mike Jolley d0438264ff Add limit to wc_load_webhooks 2019-02-18 13:15:32 +00:00
Mike Jolley 0c53145f2b Removed limit option from get_webhooks_ids - since transient stores all ids anyway, this logic makes more sense elsewhere 2019-02-18 13:13:59 +00:00
Mike Jolley 30db8a8d9c version comment 2019-02-18 13:07:57 +00:00
Mike Jolley a662934355 phpcs 2019-02-18 12:53:59 +00:00
Brent Shepherd 21d724c65d PHPCS fixes
Add fixes required for Travis to pass the PR, but which aren't
related to the PR diff.
2019-01-18 14:30:35 +10:00
Brent Shepherd 9fdbb124ae Add $limit param to wc_load_webhooks()
And the corresponding data stores. Defaults to null, meaning do not
limit, for backward compatibility.
2019-01-18 14:30:35 +10:00
Brent Shepherd 67bf101aaf Add $status param to wc_load_webhooks()
And the corresponding data stores. Defaults to '', meaning do not
load only webhooks with a specific status. This maintains backward
compatibility. However, the call to wc_load_webhooks() within
WooCommerce::load_webhooks() can now only load active webhooks, as
they are the only ones that should be enqueued.
2019-01-18 14:29:34 +10:00
Mike Jolley 9644241cef update from master 2019-01-08 14:51:05 +00:00
Brent Shepherd 0593450ed3 Make webhooks scheduled actions unique
Fixes #22087
2019-01-04 14:27:08 +00:00
Gerhard 189f346c2e Add unit tests for wc_is_webhook_valid_status 2018-12-12 10:33:52 +02:00
Gerhard 1ac267992d Add new wc_is_webhook_valid_status and use that for the schema check in the API. 2018-12-12 10:21:59 +02:00
claudiulodro b0b3ddccb0 remove extra parens 2018-11-02 10:21:30 -07:00
claudiulodro 0fa1448cfe Topic blacklist 2018-11-02 10:21:30 -07:00
Claudio Sanches f765b47cbf Make easy to register new REST API versions into webhooks
Closes #21697
2018-10-29 19:31:47 -03:00
Brent Shepherd d9158a8c0e Add WC_Queue and WC()->queue() wrapper for accessing it
To take care of instantiating a canonical job queue for use across
all of WooCommerce, and by 3rd party code.

Also use this new API for enqueuing webhooks instead of raw Action
Scheduler APIs.
2018-07-31 12:21:07 +10:00
Brent Shepherd 3993126f78 Set array keys on scheduled webhook action
To make it clearer in the database what the args refer to, e.g.
instead of storing the scheduled action's args as:

[1,123]

This patch changes it so that the args are stored as:

["webhook_id":1,"arg":123]

This has no impact on callbacks on the hooks, they are still passed
the args as normal.
2018-07-06 15:41:22 +10:00
Brent Shepherd 9aee2fa97b Add webhook group for scheduled aysnc deliveries
This will make it possible in future to run queues specifically for
delivering webhooks, instead of deliering webhooks in the same queue
as other actions, like scheduled payments, emails or other actions
scheduled by other plugins. This can be used to provide better
control over webhook delivery, which allows for sending webhooks more
quickly than if they are only included in batches of other actions.
2018-07-06 15:41:22 +10:00
Brent Shepherd f28f809edb Use Action Scheduler for async webhook delivery 2018-07-06 15:41:22 +10:00
TheDramatist a42acd438d PHPDoc @throws Added (#20381) 2018-06-05 13:30:16 +01:00
Claudio Sanches a597ba3b84 Use short ABSPATH check 2018-03-08 18:31:01 -03:00
Rodrigo Primo 211ec9b896 phpcs fixes 2018-01-31 11:22:33 -02:00
Mike Jolley b230d6be4c Error checking 2018-01-31 10:40:06 +00:00
Claudio Sanches b1fd3134c3 Introduces woocommerce_webhook_process_delivery hook 2017-12-01 14:33:30 -02:00
Claudio Sanches bf6436e0c9 Cache search webhooks results and added method to count webhooks by status 2017-11-07 17:42:14 -02:00
Claudio Sanches cf95a67f7c Added function to get webhook instance 2017-11-07 16:10:12 -02:00
Claudio Sanches 7043245cb5 Merge branch 'master' into feature/webhook-crud 2017-11-07 12:42:28 -02:00
Claudio Sanches b775074900 Fixed includes/wc-webhook-functions.php and removed debug 2017-10-10 12:59:04 -03:00
Claudio Sanches b62b954f19 Small change to test PHPCS into Travis CI 2017-10-09 17:32:53 -03:00
Claudio Sanches 8d8ffb6e9e Included @since tag to wc_is_webhook_valid_topic() 2017-08-18 13:41:51 -03:00
Claudio Sanches e31da15959 Improve test_wc_load_webhooks() checking when returns false 2017-08-17 12:32:30 -03:00
Claudio Sanches 8c120da100 Test webhook functions 2017-08-17 12:29:34 -03:00
Claudio Sanches bc95b1c153 Moved wc_is_webhook_valid_topic to wc-webhook-functions.php 2017-08-17 12:06:45 -03:00
Claudio Sanches dcf3e27155 New helpers to load webhooks 2017-08-17 10:51:20 -03:00
Claudio Sanches 53552f8028 Require create webhook secret in the REST API 2016-06-27 21:55:54 -03:00
Claudio Sanches df075875b4 Improved wc_webhook_generate_secret() 2016-06-24 14:32:06 -03:00
Claudio Sanches fd5d1e2085 Improve webhook secret generation in admin screen 2016-06-24 12:22:07 -03:00
Claudio Sanches 47ef7e17a1 Created new function to generate webhook secrets based on the user ID and username, closes #10881 2016-05-11 13:14:00 -03:00
Claudio Sanches 5893875b0c Removed period for file headers 2015-11-03 11:53:50 -02:00
Claudio Sanches ee30b5b308 Fixed php docs standards 2015-11-03 11:31:20 -02:00
Claudio Sanches b247997bd2 Created method to get the webhook statuses 2014-12-16 18:54:48 -02:00