Repository navigation
Fix Orders & Transactions timing out before the 11.0.0 database update finishes - #3490
Merged
Merged
Conversation
Before the 11.0.0 _llms_has_transaction backfill finishes, the month list excluded orders with transactions through an ID NOT IN ( SELECT ... ) subquery that runs once per order. Reuse the cached order ID list the main query already uses. Fixes #3488 Amp-Thread-ID: https://ampcode.com/threads/T-01a1e448-7786-70b5-85e1-0b6cbb96299b Co-authored-by: brianhogg <brian@brianhogg.com>
Avoids interpolating a built SQL clause, which plugin checkers flag. The order IDs become %d placeholders; an empty list uses ID 0, which matches no post. Refs #3488 Amp-Thread-ID: https://ampcode.com/threads/T-01a1e448-7786-70b5-85e1-0b6cbb96299b Co-authored-by: brianhogg <brian@brianhogg.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HS-282689
Description
The All Dates filter on Orders & Transactions lists the months that have rows in the table.
LLMS_Table_Orders_Transactions::get_available_months()builds that list and leaves out orders that have a transaction, because the table shows those as transaction rows instead.Until the 11.0.0 database update finishes its
_llms_has_transactionbackfill (lifterlms_db_version< 11.0.0), the method excludes those orders withp.ID NOT IN ( SELECT meta_value FROM wp_postmeta WHERE meta_key = '_llms_order_id' ). MariaDB runs that as a dependent subquery for every order and transaction row, so on a large store the Orders & Transactions page doesn't load until the update finishes. On sites behind Cloudflare it fails with Error 524.The main table query in the same state already avoids this. It loads the order IDs once with
get_order_ids_with_transactions()(cached) and passes them aspost__not_in. The month query now reuses that list. After the update finishes, nothing changes: the flag-based query is used as before.Fixes #3488
How has this been tested?
On MariaDB 11.4 with a synthetic dataset (16,000 orders, 22,000 transactions, 200,000 other posts, about 2.8 million postmeta rows):
max_statement_time)To check the result is the same, both queries ran on a smaller dataset where the original finishes: 2,000 orders and 2,500 transactions with mixed
trash,auto-draft, and normal statuses, some trashed orders, and transactions pointing at a subset of orders. Both returned the same 182 months. Without the exclusion there are 199, so the comparison covers excluded orders.The existing
test_available_months_excludes_orders_with_transactionstest runs on the post-update path; PHPUnit wasn't run locally and will run in CI.php -land PHPCS (phpcs.xml) pass on the changed file.Screenshots
N/A
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: