Opened 17 years ago
Closed 13 years ago
#11823 closed enhancement (fixed)
Improve SQL query used by get_terms()
| Reported by: | sirzooro | Owned by: | filosofo |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.7 |
| Component: | Taxonomy | Version: | 3.0 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
Description
#11076 / [12658] changes get_terms() so it uses SQL query with multiple conditions in WHERE clause - one for each included / excluded term. It will be better to change generated SQL from:
AND (t.term_id = 1 OR t.term_id = 2 OR ...) AND (t.term_id <> 1 AND t.term_id <> 2 AND ...)
to:
AND t.term_id IN (1, 2, ...) AND t.term_id NOT IN (1, 2, ...)
Attachments (6)
Change History (17)
#4
@
16 years ago
instead of those ugly loops, something similar to this might be possible?
$interms = array_map('intval', $interms);
$inclusions = ' AND t.term_id IN ( ' . implode(',', $interms) . ' )';
(note, Untested, and havnt looked at the code closer than the patch)
#5
@
13 years ago
- Milestone Future Release → 3.7
Refreshed, we should be using IN and NOT IN in most of these old functions that accept arrays of IDs
#6
@
13 years ago
11823.2.diff fixes a bug in the exclude_tree handling (the current patch will only exclude the last tree in the array).
#10
@
13 years ago
- Keywords commit removed
- Resolution fixed
- Status closed → reopened
[25162] causes a database error if an include or exclude argument is not empty, but is also not really a term id. 11823.4.diff addresses that.
For reference, here's a sample SQL query it generates (note that 0):
SELECT t.*, tt.* FROM wptests_terms AS t INNER JOIN wptests_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('post_tag')0 ORDER BY t.name ASC
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
OK, looks that I have to provide a patch for this :)