Define ManualLogEntryBeforePublish hook
authorPiotr Miazga <piotr@polishdeveloper.pl>
Wed, 13 Mar 2019 20:16:39 +0000 (21:16 +0100)
committerPiotr Miazga <piotr@polishdeveloper.pl>
Mon, 18 Mar 2019 23:49:53 +0000 (00:49 +0100)
This hook is required by extensions like MobileFrontend to tag
log entries when actions are performed on the mobile web.

There is a possibility to tag log entries by using
'RecentChange_save' hook, but that works only when the log entry
is published to 'rc' or 'rcandudp'. This means, that tagged log
will appear also on the Special:RecentChanges page which is something
what extensions like 'Thanks' wants to avoid.

In the future we should avoid using 'RecentChange_save' as an
indirect way to tag log entries, and use the
'ManualLogEntryBeforePublish' hook instead.

To cover ourselves in the future, instead of passing &$tags only,
we pass the $this (the log entry object) so extensions can perform
additional checks before using setTags().

Bug: T215675
Change-Id: I747eded4bc5406cd5d4676fc93b0bb55c99f9a4d

RELEASE-NOTES-1.33
docs/hooks.txt
includes/logging/LogEntry.php

index d2abed5..646a9c2 100644 (file)
@@ -91,6 +91,8 @@ For notes on 1.32.x and older releases, see HISTORY.
 * Special:ActiveUsers will no longer filter out users who became inactive since
   the last time the active users query cache was updated.
 * (T215675) RecentChange and ManualLogEntry implement new Taggable interface.
+* (T215675) Added a hook, ManualLogEntryBeforePublish, to allow extensions
+  to modify (example: add tags) log entries.
 
 === New developer features in 1.33 ===
 * The AuthManagerLoginAuthenticateAudit hook has a new parameter for
index 9e6ed10..4ef680a 100644 (file)
@@ -2210,6 +2210,10 @@ ResourceLoaderGetConfigVars instead.
   Skin::makeVariablesScript
 $out: The OutputPage which called the hook, can be used to get the real title.
 
+'ManualLogEntryBeforePublish': Allows to access or modify log entry just before it is
+published.
+$logEntry: ManualLogEntry object
+
 'MarkPatrolled': Before an edit is marked patrolled.
 $rcid: ID of the revision to be marked patrolled
 &$user: the user (object) marking the revision as patrolled
index 19dcf0d..33dd69b 100644 (file)
@@ -797,6 +797,7 @@ class ManualLogEntry extends LogEntryBase implements Taggable {
                        function () use ( $newId, $to ) {
                                $log = new LogPage( $this->getType() );
                                if ( !$log->isRestricted() ) {
+                                       Hooks::runWithoutAbort( 'ManualLogEntryBeforePublish', [ $this ] );
                                        $rc = $this->getRecentChange( $newId );
 
                                        if ( $to === 'rc' || $to === 'rcandudp' ) {