WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#10510 closed defect (bug) (fixed)

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

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

Description

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 5 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 josephscott5 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';
        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.

josephscott5 years ago

comment:2 westi5 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.

comment:3 Denis-de-Bernardy4 years ago

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