From 6b1b25fad3bfe6418f6b0e550e3e4509668a7a27 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Tue, 5 Nov 2013 00:02:54 -0800 Subject: [PATCH] Move ManualLogEntry to RecentChange logic into own function There are certain cases where extensions might want to get a RecentChanges object without actually inserting it into the recentchanges table. Change-Id: I2873c648285a2918661c3650bb90e8db0e05c40c --- includes/logging/LogEntry.php | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/includes/logging/LogEntry.php b/includes/logging/LogEntry.php index b2a8e50d30..a1cb3a7c7c 100644 --- a/includes/logging/LogEntry.php +++ b/includes/logging/LogEntry.php @@ -498,16 +498,12 @@ class ManualLogEntry extends LogEntryBase { } /** - * Publishes the log entry. - * @param int $newId id of the log entry. - * @param string $to rcandudp (default), rc, udp + * Get a RecentChanges object for the log entry + * @param int $newId + * @return RecentChange + * @since 1.23 */ - public function publish( $newId, $to = 'rcandudp' ) { - $log = new LogPage( $this->getType() ); - if ( $log->isRestricted() ) { - return; - } - + public function getRecentChange( $newId = 0 ) { $formatter = LogFormatter::newFromEntry( $this ); $context = RequestContext::newExtraneousContext( $this->getTarget() ); $formatter->setContext( $context ); @@ -524,7 +520,7 @@ class ManualLogEntry extends LogEntryBase { $ip = $user->getName(); } } - $rc = RecentChange::newLogEntry( + return RecentChange::newLogEntry( $this->getTimestamp(), $logpage, $user, @@ -539,6 +535,21 @@ class ManualLogEntry extends LogEntryBase { $formatter->getIRCActionComment() // Used for IRC feeds ); + } + + /** + * Publishes the log entry. + * @param int $newId id of the log entry. + * @param string $to rcandudp (default), rc, udp + */ + public function publish( $newId, $to = 'rcandudp' ) { + $log = new LogPage( $this->getType() ); + if ( $log->isRestricted() ) { + return; + } + + $rc = $this->getRecentChange( $newId ); + if ( $to === 'rc' || $to === 'rcandudp' ) { $rc->save( 'pleasedontudp' ); } -- 2.20.1