WordPress.org

Make WordPress Core

Opened 8 months ago

Closed 7 months ago

#25231 closed enhancement (fixed)

wp_ajax_ajax_tag_search should use get_terms instead of a custom query

Reported by: Chouby Owned by: nacin
Milestone: 3.7 Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch
Focuses: Cc:

Description

The goal is to take profit of all advantages of the get_terms function: cache, filters...

Attachments (1)

25231.patch (709 bytes) - added by Chouby 8 months ago.

Download all attachments as: .zip

Change History (5)

Chouby8 months ago

comment:1 Chouby8 months ago

  • Keywords has-patch added

comment:2 SergeyBiryukov8 months ago

  • Milestone changed from Awaiting Review to 3.7

comment:3 nacin7 months ago

Before: SELECT t.name FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.name LIKE (%s)"

After: SELECT t.term_id, tt.parent, tt.count, t.name FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('post_tag') AND t.name LIKE '%apple%' ORDER BY t.name ASC

name__like has two underscores. Also, this wouldn't have been possible without [25241]. I also like the ORDER BY, though it would probably be better to match based on LIKE '$name', then LIKE '$name%', then finally LIKE '%$name%'. This doesn't change functionality, though, so looks good.

comment:4 nacin7 months ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 25452:

Use get_terms() in the ajax tag search.

props Chouby.
fixes #25231.

Note: See TracTickets for help on using tickets.