Make WordPress Core

Opened 13 months ago

Closed 13 months ago

Last modified 13 months ago

#64042 closed defect (bug) (invalid)

Media / REST API: duplicate records in paginated results when filtering by media_type

Reported by: ramonopoly Owned by:
Priority: normal Milestone:
Component: REST API Version:
Severity: normal Keywords:
Cc: Focuses: rest-api

Description

In the attachments REST API endpoint, the endpoint returns the same attachment record over subsequent pages when filtering by media_type.

For example, given 25 attachment posts, the first request will return 20 records:

/wp-json/wp/v2/media?context=view&per_page=20&page=1&media_type=image

like so:

[ ...records, { id: 18, ...fields } ]

the request for the second page,

/wp-json/wp/v2/media?context=view&per_page=20&page=2&media_type=image

returns the remaining five

[ ...records, { id: 18, ...fields }, ...records ]

It appears to be true regardless of the per_page value or how many records exist.

Change History (4)

#1 @ramonopoly
13 months ago

Actually, I can't reproduce any more on WordPress trunk :-)

I'll test again and close this ticket if I've taken a wrong turn somewhere.

#2 @ramonopoly
13 months ago

  • Milestone Awaiting Review
  • Resolution → invalid
  • Status new → closed

#3 @ramonopoly
13 months ago

I actually think the cause of the bug is related to #40376

Last edited 13 months ago by ramonopoly (previous) (diff)
Note: See TracTickets for help on using tickets.