[wp-trac] [WordPress Trac] #14868: Inconsistent return type calling wp.newCategory method via XML-RPC

WordPress Trac wp-trac at lists.automattic.com
Tue Sep 14 15:38:46 UTC 2010


#14868: Inconsistent return type calling wp.newCategory method via XML-RPC
--------------------------+-------------------------------------------------
 Reporter:  mwidmann      |       Owner:                 
     Type:  defect (bug)  |      Status:  new            
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  XML-RPC       |     Version:  3.0.1          
 Severity:  normal        |    Keywords:                 
--------------------------+-------------------------------------------------
 Calling the XML-RPC method {{{wp.newCategory}}} doesn't always return
 {{{int}}} as described in the Codex or the inline documentation, but also
 returns {{{string}}} values with the new ids.

 Example call:
 {{{
 <?xml version="1.0"?>
 <methodCall>
   <methodName>wp.newCategory</methodName>
   <params>
     <param>
       <value>
         <string>1</string>
       </value>
     </param>
     <param>
       <value>
         <string>USERNAME</string>
       </value>
     </param>
     <param>
       <value>
         <string>PASSWORD</string>
       </value>
     </param>
     <param>
       <value>
         <struct>
           <member>
             <name>name</name>
             <value>
               <string>vol</string>
             </value>
           </member>
           <member>
             <name>parent_id</name>
             <value>
               <string>0</string>
             </value>
           </member>
           <member>
             <name>description</name>
             <value>
               <string />
             </value>
           </member>
         </struct>
       </value>
     </param>
   </params>
 </methodCall>
 }}}

 You can call it using {{{wget}}} on the shell like this:

 {{{
  $ wget -S -O - --post-file=/tmp/post-body.txt
 http://URL_TO_YOUR_3.0.1_INSTALLATION/xmlrpc.php
 }}}

 The Response will look like this:

 {{{
 <?xml version="1.0"?>
 <methodResponse>
   <params>
     <param>
       <value>
         <string>7</string>
       </value>
     </param>
   </params>
 </methodResponse>
 }}}

 If you call it a second time it will return the category id for the
 existing category in this form:

 {{{
 <?xml version="1.0"?>
 <methodResponse>
   <params>
     <param>
       <value>
         <int>7</int>
       </value>
     </param>
   </params>
 </methodResponse>
 }}}

 I'm trying to write an import application using C# using xml-rpc.net to
 migrate ~1k categories and ~800k contents to WordPress and this is a bit
 of a blocker for me.

 The easiest fix could be to just replace line 946 in {{{xmlrpc.php}}}
 with
 {{{
 return (int) $cat_id;
 }}}

 In order to always return {{{int}}}

 In the meanwhile I'll extend xmlrpc_methods with a copy of the method and
 the fix.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14868>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list