Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.1.2 #14

Merged
merged 3 commits into from
Apr 17, 2020
Merged

Version 1.1.2 #14

merged 3 commits into from
Apr 17, 2020

Conversation

stevegrunwell
Copy link
Contributor

Fixed

stevegrunwell and others added 3 commits April 17, 2020 15:39
`OrderLimiter::count_qualifying_orders()` relies on `wc_get_orders()`, which is several layers of abstraction over `WP_Query`.

Currently, if we analyze the query, it looks something like this:

```sql
SELECT wptests_posts.ID
FROM wptests_posts
WHERE 1=1
AND ( wptests_posts.post_date_gmt >= '2020-04-17 00:00:00' )
AND wptests_posts.post_type = 'shop_order'
AND (
    (
           wptests_posts.post_status = 'wc-pending'
        OR wptests_posts.post_status = 'wc-processing'
        OR wptests_posts.post_status = 'wc-on-hold'
        OR wptests_posts.post_status = 'wc-completed'
        OR wptests_posts.post_status = 'wc-cancelled'
        OR wptests_posts.post_status = 'wc-refunded'
        OR wptests_posts.post_status = 'wc-failed'
    )
)
ORDER BY wptests_posts.post_date DESC LIMIT 0, 10
```

Unfortunately, that last line is the problem: we're limiting the qualifying orders to 10, which is the default LIMIT value for `WP_Query`.

This commit overrides that default, setting it to either the limit set by the store _or_ `1000` (whichever is higher); this ensures that we're not running a `-1` limit on a store that could potentially have a very large threshold for orders (e.g. "oh, we only want to accept 1M orders/week").

Eventually, it may be worth rewriting this function to use an explicit SQL `COUNT(*)` query (thus eliminating limit concerns), but we want to ensure we do that in a way that maintains compatibility with WooCommerce's CRUD APIs.

This should also resolve the two open support tickets on WordPress.org:

1. https://wordpress.org/support/topic/limit-orders-did-not-work/
2. https://wordpress.org/support/topic/orders-have-exceeded-the-limit/
Override the default MySQL query limit when counting orders
@stevegrunwell stevegrunwell added the release Preparing for a release label Apr 17, 2020
@stevegrunwell stevegrunwell added this to the 1.1.2 milestone Apr 17, 2020
@stevegrunwell stevegrunwell requested a review from bswatson April 17, 2020 16:28
@stevegrunwell stevegrunwell merged commit bd3acb9 into master Apr 17, 2020
@stevegrunwell stevegrunwell deleted the release/v1.1.2 branch April 17, 2020 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release Preparing for a release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants