WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#22204 closed defect (bug) (fixed)

XML-RPC _insert_post error when updating a post with a thumbnail.

Reported by: picklepete Owned by: ryan
Milestone: 3.5 Priority: normal
Severity: major Version: 3.4.2
Component: XML-RPC Keywords: has-patch commit
Focuses: Cc:
PR Number:

Description

Versions affected: 3.4+
Summary: Updating a post with wp_editPost is throwing an "Invalid attachment ID" error due to a change to set_post_thumbnail in 3.4. In 3.3.3 and earlier "true" was always returned. Now, when the post_thumbnail is compared against the existing post_thumbnail the "false" which is returned bubbles up to set_post_thumbnail and an "Invalid attachment ID" is thrown.

The attached patch satisfies two needs:

  1. That the attachment's existence is tested, and if it's invalid, an "Invalid attachment ID" error is thrown.
  2. That it should be possible for set_post_thumbnail to execute and return false, which it will if the post thumbnail hasn't been changed.

Attachments (1)

insert_post.patch (636 bytes) - added by picklepete 7 years ago.

Download all attachments as: .zip

Change History (4)

#1 @picklepete
7 years ago

How to replicate:

<?php
    require 'wp-config.php';
    require 'wp-includes/class-IXR.php';
    require 'wp-includes/class-wp-xmlrpc-server.php';

    $post_ID = 4117;
    $post_data = array('ID' => $post_ID, 'post_thumbnail' => '3964');  // Real attachment ID

    $server = new wp_xmlrpc_server();
    var_dump($server->wp_editPost(array(
        1,
        'username',
        'password',
        $post_ID,
        $post_data
    )));

#2 @nacin
7 years ago

  • Keywords commit added
  • Milestone changed from Awaiting Review to 3.5

set_post_thumbnail() can indeed return false if the row wasn't updated because the thumbnail was already set to that ID.

#3 @ryan
7 years ago

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

In [22277]:

In wp_xmlrpc_server::_insert_post(), don't return an error if set_post_thumbnail() returns false when the attachment ID doesn't change.

Props picklepete
fixes #22204

Note: See TracTickets for help on using tickets.