From 384ab964cdde099637e2dbdefa6957ab944b4dd8 Mon Sep 17 00:00:00 2001 From: Piotr Miazga Date: Wed, 13 Mar 2019 21:16:39 +0100 Subject: [PATCH] Define ManualLogEntryBeforePublish hook 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 | 2 ++ docs/hooks.txt | 4 ++++ includes/logging/LogEntry.php | 1 + 3 files changed, 7 insertions(+) diff --git a/RELEASE-NOTES-1.33 b/RELEASE-NOTES-1.33 index d2abed54ce..646a9c24f0 100644 --- a/RELEASE-NOTES-1.33 +++ b/RELEASE-NOTES-1.33 @@ -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 diff --git a/docs/hooks.txt b/docs/hooks.txt index 9e6ed10fc9..4ef680ab0c 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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 diff --git a/includes/logging/LogEntry.php b/includes/logging/LogEntry.php index 19dcf0d811..33dd69b8fd 100644 --- a/includes/logging/LogEntry.php +++ b/includes/logging/LogEntry.php @@ -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' ) { -- 2.20.1