Make WordPress Core

Opened 14 years ago

Closed 11 years ago

Last modified 9 years ago

#13992 closed enhancement (fixed)

get_terms() has 'search' and 'name__like'

Reported by: dd32's profile dd32 Owned by: wonderboymusic's profile wonderboymusic
Milestone: 3.7 Priority: normal
Severity: normal Version: 3.0
Component: Taxonomy Keywords: has-patch commit
Focuses: Cc:

Description (last modified by SergeyBiryukov)

Both do similar things:

	if ( !empty($name__like) )
		$where .= " AND t.name LIKE '{$name__like}%'";
...

	if ( !empty($search) ) {
		$search = like_escape($search);
		$where .= " AND (t.name LIKE '%$search%')";
	}

name__like should be removed in favour of search IMO, unless that functionality is intended, and in that case, name__like should get like_escape() applied

Attachments (3)

13992.diff (675 bytes) - added by wojtek.szkutnik 14 years ago.
13992.2.diff (593 bytes) - added by wonderboymusic 11 years ago.
13992.3.diff (1.5 KB) - added by wonderboymusic 11 years ago.

Download all attachments as: .zip

Change History (17)

#1 @dd32
14 years ago

  • Keywords needs-patch added

#2 @dd32
14 years ago

in addition to that, Terms are stored in the database htmlspecialchar'd by the looks of it (ie. '&'), The search should take that into consideration and apply the same filtering to the searching term.

#3 @filosofo
14 years ago

I would prefer removing 'search' instead, as it's unclear what fields are actually being searched.

#4 @dd32
14 years ago

After thinking a bit more

  • name__like should get escaped, and work as it currently does
  • search should do both name AND slug, Not sure description is worth it?

#5 @wojtek.szkutnik
14 years ago

  • Cc wojtek.szkutnik@… added
  • Keywords has-patch added; needs-patch removed

#6 @wojtek.szkutnik
14 years ago

  • Keywords gsoc added

Added diff that includes your suggestions, with search looking for name OR slug. No need to include description IMO.

#7 @kevinB
14 years ago

  • Cc kevinB added

#8 @nacin
14 years ago

  • Milestone changed from Awaiting Triage to Future Release
  • Type changed from defect (bug) to enhancement

#9 @wonderboymusic
11 years ago

  • Keywords gsoc removed
  • Milestone changed from Future Release to 3.7

Refreshed against trunk, only thing missing from trunk is the search for name AND slug

#10 @wonderboymusic
11 years ago

  • Keywords commit added

.3.diff has unit tests

#11 @SergeyBiryukov
11 years ago

  • Description modified (diff)

#12 @nacin
11 years ago

Looks good.

#13 @wonderboymusic
11 years ago

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

In 25164:

Search term name and slug when the search arg is passed to get_terms(). Adds unit test.

Props wojtek.szkutnik.
Fixes #13992.

#14 @boonebgorges
9 years ago

In 37519:

Tests: get_terms() 'search' test should have more precise fixtures..

Without a fixture that does not match the search term, it's possible for the
test to pass even if the search clause isn't built properly.

See #13992, #35381.

Note: See TracTickets for help on using tickets.