Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 23 months ago

#44618 closed defect (bug) (invalid)

Returning all posts by searching for "-something" using the REST API

Reported by: parsaasefi Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.9.7
Component: REST API Keywords:
Focuses: Cc:


By searching for "-" character in posts using the REST API it will return an empty array even if there is some related posts but by searching for "-something" (-anything) the REST API will return all the posts even if they are not related!

Change History (2)

#1 @earnjam
2 years ago

  • Resolution set to invalid
  • Status changed from new to closed

This is expected behavior. The REST API uses WP_Query for gathering results. If you supply a hyphen before a word, then WP_Query uses that as an exclude word for result sets. Try it with a common word and you'll see that posts containing that word are not returned.

Regarding passing only a hyphen, searches using single A-Z characters or hyphens are treated as invalid and return no results.

#2 @netweb
23 months ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.