WordPress.org

Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 6 years ago

#14067 closed defect (bug) (fixed)

WP3.0 XMLRPC wp.newCategory fails for existing category

Reported by: andrewpeacock Owned by:
Milestone: 3.0.1 Priority: normal
Severity: major Version: 3.0
Component: XML-RPC Keywords: xmlrpc has-patch needs-testing
Focuses: Cc:
PR Number:

Description (last modified by ryan)

Hi,
I'm comparing 2.9.2 and 3.0 with the same remote client calling WP's XMLRPC, as follows:

<?php
require("class.xmlrpc.php");
$client = new IXR_Client("URL");
$client->debug = true;
$content = Array();
$content["name"] = "1-800-PetMeds";
if (!$client->query('wp.newCategory', "", "USERNAME", "PASSWORD", $content)) {
	die('Something went wrong - '.$client->getErrorCode().' : '.$client->getErrorMessage());
} else {
	$categoryID = $client->getResponse();
}
?>

On 2.9.2:

  • If the category name is not in use, the category is created and the new ID returned.
  • If the category name is in use, the existing ID is returned.

On 3.0:

  • If the category name is not in use, the category is created and the new ID returned.
  • If the category name is in use, a generic XMLRPC is returne:

<?xml version="1.0"?>
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value><int>500</int></value>
</member>
<member>
<name>faultString</name>
<value><string>Sorry, the new category failed.</string></value>
</member>
</struct>
</value>
</fault>
</methodResponse>

Attachments (1)

14067.diff (1.5 KB) - added by ryan 9 years ago.

Download all attachments as: .zip

Change History (9)

#1 @nacin
9 years ago

  • Milestone changed from Unassigned to 3.0.1
  • Severity changed from critical to major

@ryan
9 years ago

#2 @ryan
9 years ago

Due to changes to wp_insert_term(). Patch (untested) returns the ID of the existing term when issuing a term_exists WP_Error. newCategory passes that ID along when it sees term_exists.

#3 @ryan
9 years ago

  • Description modified (diff)

#4 @ryan
9 years ago

  • Keywords has-patch needs-testing added

#5 @ryan
9 years ago

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

(In [15425]) If category already exists, return its ID. Restores previous behavior. fixes #14067 for 3.1

#6 @ryan
9 years ago

(In [15426]) If category already exists, return its ID. Restores previous behavior. fixes #14067 for 3.0.1

#7 follow-up: @techaddict
6 years ago

wp.newCategory returns wrong category id when the passed category is sub category.

example :

A is parent category with ID 1 and B is child/sub category with ID 2 of it
C is parent category with ID 3 and B is child/sub category with ID 4 of it

So when we pass

'name' => 'B',
'slug' => 'B',
'parent_id'=>'3'

It should return 4 but it returns 2.

#8 in reply to: ↑ 7 @SergeyBiryukov
6 years ago

Replying to techaddict:

wp.newCategory returns wrong category id when the passed category is sub category.

This ticket was closed on a completed milestone. Please create a new one if there's still a problem.

Note: See TracTickets for help on using tickets.