Manual:Hooks/Comment::delete

Category:Extension hooks#Comment::delete
Comment::delete
Available from version ???
Allows things to happen after a comment has been removed from the database and potential notifications etc. have run.
Define function:
public static function onComment_delete( $comment, $id, $pageId ) { ... }
Attach hook:
$wgHooks['Comment::delete'][] = 'MyExtensionHooks::onComment_delete';
Called from:File(s): Category:Extension hooks provided by CommentsComments / includes/Comment.php
Function(s): delete

For more information about attaching hooks, see Manual:Hooks .
For examples of other extensions using this hook, see Category:Comment::delete extensions.

The Comment::delete hook is called after a comment has been deleted, right before the Comment::delete method returns a value. The hook provides access to the Comment object ($comment), the ID of the recently deleted comment ($id) and the ID of the page which contains the <code<comments /> tag ($pageId).

As of Q3/2025 the only extension using this hook is LinkFilter: when a comment is deleted from a Link: page, the hook subscriber decrements the link_comment_count field in the link table by one.

See also