Jump to content

Extension:Comments/Hooks/Comment::add

From mediawiki.org
Comment::add
Available from version ???
Allows things to happen after a new comment has been inserted into the database and potential notifications etc. have run.
Define function:
public static function onComment_add( $comment, $commentId, $commentPageId ) { ... }
Attach hook:
$wgHooks['Comment::add'][] = 'MyExtensionHooks::onComment_add';
Called from:
File(s): Comments / includes/Comment.php
Function(s): add

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

The Comment::add hook is called after a new comment has been added to the database, right before the Comment::add method returns a value. The hook provides access to the Comment object ($comment), the ID of the recently added comment ($commentId) and the ID of the page which contains the <code<comments /> tag ($commentPageId).

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

See also

[edit]