Make WordPress Core

Opened 2 years ago

Closed 8 weeks ago

#25406 closed enhancement (fixed)

XMLRPC wp_getPosts $filter argument should support more values

Reported by: wordpressplugindeveloper Owned by: chriscct7
Milestone: 4.4 Priority: normal
Severity: normal Version: 3.8
Component: XML-RPC Keywords: dev-feedback has-patch commit
Focuses: Cc:


Although "see get_posts() for more on $filter values" is written in the doc, it actually supports
'post_type', 'post_status', 'number', 'offset', 'orderby', and 'order' only, and there is one hidden value 's' that didn't mention in the doc.

Currently, the $filter argument is handled by function wp_getPosts like this:

$query = array();
if ( isset( $filter['offset'] ) )
     $query['offset'] = absint( $filter['offset'] );
wp_get_recent_posts( $query );

I think it'd be better if you can use get_posts() instead and simply pass $filter as its argument.

just my 2 cents though.

Attachments (1)

25406.patch (814 bytes) - added by chriscct7 2 months ago.

Download all attachments as: .zip

Change History (4)

#1 @maxcutler
21 months ago

  • Keywords dev-feedback added

That @see line that you quoted is meant as a modifier on the paragraph above:

The optional $filter parameter modifies the query used to retrieve posts.
Accepted keys are 'post_type', 'post_status', 'number', 'offset', 'orderby', and 'order'.

You're right that there's a doc bug that the s filter is missing both in code and in the Codex, that probably deserves a simple patch.

With regards to the suggestion to pass through $filter to wp_get_recent_posts, I think the core devs had some reservations about that approach when we added this in 3.4. It would be nice to have more filter parameters for richer querying, but there might have been security/compatibility/performance concerns that made us not do this originally.

2 months ago

#2 @chriscct7
2 months ago

  • Keywords has-patch commit added; needs-patch removed
  • Milestone changed from Awaiting Review to 4.4
  • Owner set to chriscct7
  • Status changed from new to assigned

Fixed the docbloc in question

#3 @wonderboymusic
8 weeks ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 34860:

XML-RPC: allow wp_xmlrpc_server::wp_getPosts() to receive s as a filter.

Props chriscct7.
Fixes #25406.

Note: See TracTickets for help on using tickets.