Move ManualLogEntry to RecentChange logic into own function
authorKunal Mehta <legoktm@gmail.com>
Tue, 5 Nov 2013 08:02:54 +0000 (00:02 -0800)
committerKunal Mehta <legoktm@gmail.com>
Tue, 5 Nov 2013 08:02:54 +0000 (00:02 -0800)
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

index b2a8e50..a1cb3a7 100644 (file)
@@ -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' );
                }