[wp-trac] Re: [WordPress Trac] #8863: wp_set_comment_status action is not raised

WordPress Trac wp-trac at lists.automattic.com
Thu Jan 15 19:37:12 GMT 2009


#8863: wp_set_comment_status action is not raised
--------------------------+-------------------------------------------------
 Reporter:  Jehan         |        Owner:  Jehan   
     Type:  defect (bug)  |       Status:  assigned
 Priority:  normal        |    Milestone:  2.7.1   
Component:  Comments      |      Version:  2.7     
 Severity:  normal        |   Resolution:          
 Keywords:                |  
--------------------------+-------------------------------------------------
Changes (by Jehan):

  * owner:  => Jehan
  * status:  new => assigned

Comment:

 Ok I have precised the bug and found the issue (hence how to fix it). In
 fact this action is raised if you change the status from the wp-admin
 /edit-comment.php, which is the page where you can check several comments
 at once then do stuffs as delete, approve, unapprove them, etc.

 But when you are in wp-admin/comment.php, which you can reach from a
 specific post, then clicking on the "Modify" button next to a comment,
 then it fails.
 The case "editedcomment" calls edit_comment () [wp-
 admin/includes/comment.php], which calls itself wp_update_comment( $_POST)
 [wp-includes/comment.php].

 The error is in this last file. When you call:
 wp_transition_comment_status($comment_approved,
 $comment->comment_approved, $comment);
 [line 1118 as of for now]
 you have updated the comment in the database just before
 ($wpdb->query(...) lines 1094 to 1110). Hence $new_status == $old_status,
 hence the function wp_transition_comment_status does not fire
 "transition_comment_status".

 Conclusion: the solution is to save the old status before running the
 query. For instance, simply add to line 1093:
 $old_status = $comment['comment_approved'];

 Tested and working on the 2.7 (not tested on the trunk, but it seems the
 same and the lines I quoted were from trunk seen on the web).

 Is it clear enough or do you need a patch for the trunk?

-- 
Ticket URL: <http://trac.wordpress.org/ticket/8863#comment:3>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list