WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#8864 closed enhancement (invalid)

add the old comment's status in the action function arguments of wp_set_comment_status

Reported by: Jehan Owned by:
Milestone: 2.8 Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

According to the doc, the action function arguments for wp_set_comment_status (which is not working right now: cf bug #8863) are the comment ID and the status string indicating the new status ("delete", "approve", "spam", "hold").

I think it would be nice to add an optional third argument: the status string indicating the former status (same: "delete", "approve", "spam", "hold") because when a comment's status change, sometimes one may be only interested by the current status; but other times, you may also be interested by the full change: from which to which status?

In a plugin I write for instance, I am publishing comments on a PubSub XMPP node, but only when approved. So if a comment goes to "spam", I will remove it from the node. But if it is changed from "hold" to "spam" for instance, it was anyway not published, so I send a delete query on an absent node (or else I must keep memory on the old status, but this is pretty unefficient).

This is not a serious drawback, but still it may avoid useless XMPP queries and I guess other people may think it to be interested by such third argument.
Thanks.

Change History (3)

comment:1 Jehan5 years ago

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

Ok, in fact it was already existing, though undocumented. It is the action "transition_comment_status", which can take up to 3 arguments: the new status, then the old status and finally the comment itself. This last argument is object comment, and not the comment id, at the opposite to wp_set_comment_status. That's not a real issue (as it is easy to pass from one to another), but still it is not very consistent from an action to another (the naming also are not always so consistent. Why sometimes begin with "wp_" and sometimes not?) and I think it is better to pass a simple integer as arguments (that you can use then to get the full comment data, if ever needed) than a full object.

So I think this can be considered as fixed. If I don't forget, I will update the doc as well.

comment:2 mrmist5 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:3 mrmist5 years ago

  • Resolution set to invalid
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.