Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#24336 closed defect (bug) (invalid)

XML RPC arguments for wp.getPosts are invalid

Reported by: bduffez Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: XML-RPC Keywords:
Focuses: Cc:


Version: WP3.5 (latest) Issue: can't use wp.getPosts XML RPC method. Error: username/password invalid Issue: PHP error File: wp-includes/class-wp-xmlrpc-server.php Line: 1433 Code:

        function wp_getPosts( $args ) {
                if ( ! $this->minimum_args( $args, 3 ) )
                        return $this->error;

                $this->escape( $args );

                $blog_id    = (int) $args[0];
                $username   = $args[1];
                $password   = $args[2];
                $filter     = isset( $args[3] ) ? $args[3] : array();

Just before the this->escape( $args ) I did a print_r of $args:

    [password] => foo
    [filter] => Array
            [post_type] => page

    [username] => bar
    [blog_id] => 1

However, as you can see, $username and $password are extracted from $args[1], $args[2] instead of $args[username] and $args[password].

Attachments (1)

xmlrpc.xml (413 bytes) - added by bduffez 5 years ago.
XML sent by the client

Download all attachments as: .zip

Change History (7)

#1 @SergeyBiryukov
5 years ago

  • Component changed from General to XML-RPC

Related: [19848]

#2 @markoheijnen
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

You can't pass array key names through the XML-RPC. See all other methods

5 years ago

XML sent by the client

#3 @bduffez
5 years ago

I'm not passing array key names through XML-RPC. My client sends the XML attached to this ticket (xmlrpc.xml). As you can see, it only contains the values 1, "foo", "bar", struct: filter[post_type] = page The only named values are the filter array, and the "page" value which has a key name of "post_type".

Am I wrong?

#4 @markoheijnen
5 years ago

It doesn't make sense what you have now. As you can see in the xmlrpc.xml there isn't defined what the key is of the values. So there is no reason that the args should have those args.

I only can see it isn't a core issue. Otherwise the mobile apps also should have issues. No clue how you get those vars.

#5 @DrewAPicture
5 years ago

@markoheijnen is correct here in saying that you can't pass array key names through. Based on your printed array, you're passing the args in the format of:

	'password' => 'foo',
	'filter' => array( 'post_type' => 'page' ),
	'username' => 'bar',
	'blog_id' => 1

when in reality, you should be passing args in the form of:

	1, // blog_id
	'bar', // username
	'foo', // password
	array( 'post_type' => 'page' ), // filter

#6 @bduffez
5 years ago

Well, it appears that I was a bit mistaken in my queries to the server, I apologize. Indeed, when using the appropriate XML query, the array is:

    [0] => 1
    [1] => foo
    [2] => bar
    [3] => Array
            [post_type] => page


which is expected. What I have yet to figure now, is why the server replies with HTTP 401, I guess it is because XML RPC expects the user to have writing rights, which is not the case because I want to create a read-only client.

However, I would like to thank you for the very quick support, and apologize again for the wrong bug report.

Cheers, Benoit

Note: See TracTickets for help on using tickets.