Removed limit option from get_webhooks_ids - since transient stores all ids anyway, this logic makes more sense elsewhere

This commit is contained in:
Mike Jolley 2019-02-18 13:13:59 +00:00
parent 30db8a8d9c
commit 0c53145f2b
3 changed files with 5 additions and 12 deletions

View File

@ -206,11 +206,9 @@ class WC_Webhook_Data_Store implements WC_Webhook_Data_Store_Interface {
* @since 3.3.0
* @throws InvalidArgumentException If a $status value is passed in that is not in the known wc_get_webhook_statuses() keys.
* @param string $status Optional - status to filter results by. Must be a key in return value of @see wc_get_webhook_statuses(). @since 3.6.0.
* @param null|int $limit Limit returned results. @since 3.6.0.
* @return int[]
*/
public function get_webhooks_ids( $status = '', $limit = null ) {
public function get_webhooks_ids( $status = '' ) {
if ( ! empty( $status ) ) {
$this->validate_status( $status );
}
@ -224,14 +222,10 @@ class WC_Webhook_Data_Store implements WC_Webhook_Data_Store_Interface {
'status' => $status,
)
);
$ids = array_map( 'intval', $ids );
$ids = array_map( 'absint', $ids );
set_transient( $this->get_transient_key( $status ), $ids );
}
if ( null !== $limit && $limit > 0 ) {
$ids = array_slice( $ids, 0, absint( $limit ) );
}
return $ids;
}

View File

@ -29,9 +29,8 @@ interface WC_Webhook_Data_Store_Interface {
*
* @since 3.2.0
* @throws InvalidArgumentException If a $status value is passed in that is not in the known wc_get_webhook_statuses() keys.
* @param string $status Optional - status to filter results by. Must be a key in return value of @see wc_get_webhook_statuses(). @since 3.5.0.
* @param null|int $limit Limit returned results. @since 3.5.0.
* @param string $status Optional - status to filter results by. Must be a key in return value of @see wc_get_webhook_statuses(). @since 3.6.0.
* @return int[]
*/
public function get_webhooks_ids( $status = '', $limit = null );
public function get_webhooks_ids( $status = '' );
}

View File

@ -135,7 +135,7 @@ function wc_get_webhook_statuses() {
*/
function wc_load_webhooks( $status = '', $limit = null ) {
$data_store = WC_Data_Store::load( 'webhook' );
$webhooks = $data_store->get_webhooks_ids( $status, $limit );
$webhooks = $data_store->get_webhooks_ids( $status );
$loaded = false;
foreach ( $webhooks as $webhook_id ) {