Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#10510 closed defect (bug) (fixed)

XMLRPC wp.getComments 'spam' status returned as 'hold'

Reported by: nigelgos's profile nigelgos Owned by: josephscott's profile josephscott
Milestone: 2.9 Priority: normal
Severity: normal Version: 2.8.1
Component: XML-RPC Keywords: XMLRPC getComments status spam
Focuses: Cc:


When requesting spam messages the status is returned as 'hold'. This means you can't differentiate between comment statuses when you ask for 'spam' and 'hold' comments to be returned.

It does return the correct comments, just the status is wrong.

Attachments (1)

xmlrpc.php.diff (719 bytes) - added by josephscott 14 years ago.

Download all attachments as: .zip

Change History (4)

#1 @josephscott
14 years ago

  • Cc joseph@… added
  • Component changed from Comments to XML-RPC
  • Owner set to josephscott

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';
            $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.

#2 @westi
14 years ago

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

(In [11783]) Ensure that XMLRPC clients can tell the difference between unapproved and spam comments. Fixes #10510 props josephscott.

#3 @Denis-de-Bernardy
14 years ago

  • Milestone changed from Unassigned to 2.9
Note: See TracTickets for help on using tickets.