[wp-trac] [WordPress Trac] #10510: XMLRPC wp.getComments 'spam' status returned as 'hold'

WordPress Trac wp-trac at lists.automattic.com
Thu Aug 6 20:09:52 UTC 2009


#10510: XMLRPC wp.getComments 'spam' status returned as 'hold'
--------------------------+-------------------------------------------------
 Reporter:  nigelgos      |       Owner:  josephscott                   
     Type:  defect (bug)  |      Status:  new                           
 Priority:  normal        |   Milestone:  Unassigned                    
Component:  XML-RPC       |     Version:  2.8.1                         
 Severity:  normal        |    Keywords:  XMLRPC getComments status spam
--------------------------+-------------------------------------------------
Changes (by josephscott):

 * cc: joseph@… (added)
  * owner:  => josephscott
  * component:  Comments => XML-RPC


Comment:

 I'm able to reproduce this.

 After looking through the path for the comment status it turns out that it
 is the value comparison checking in the wp_getComment function that was
 causing the confusion:

 {{{
         if ( 0 == $comment->comment_approved )
             $comment_status = 'hold';
         else if ( 'spam' == $comment->comment_approved )
             $comment_status = 'spam';
         else if ( 1 == $comment->comment_approved )
             $comment_status = 'approve';
         else
             $comment_status = $comment->comment_approved;
 }}}

 The comment approved field is a string.  This was tripping up comments
 with 'spam' status and indicating that there were 'hold'.  By quoting the
 numeric comparisons for the zero and one values the conditional checks
 work as expected.  After making this change my tests show that the XML-RPC
 method wp.getComment (and wp.getComments) return the correct status values
 of hold, approve and spam.

 I've attached a diff to make this change.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/10510#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list