Fix some RecentChange phpdoc return types
[lhc/web/wiklou.git] / includes / changes / RecentChange.php
index 86cd1d7..13e94db 100644 (file)
@@ -164,7 +164,7 @@ class RecentChange {
         * Obtain the recent change with a given rc_id value
         *
         * @param int $rcid The rc_id value to retrieve
-        * @return RecentChange
+        * @return RecentChange|null
         */
        public static function newFromId( $rcid ) {
                return self::newFromConds( array( 'rc_id' => $rcid ), __METHOD__ );
@@ -176,7 +176,7 @@ class RecentChange {
         * @param array $conds Array of conditions
         * @param mixed $fname Override the method name in profiling/logs
         * @param array $options Query options
-        * @return RecentChange
+        * @return RecentChange|null
         */
        public static function newFromConds( $conds, $fname = __METHOD__, $options = array() ) {
                $dbr = wfGetDB( DB_SLAVE );
@@ -332,6 +332,11 @@ class RecentChange {
                                        $this->mExtra['pageStatus'] );
                        }
                }
+
+               // Update the cached list of active users
+               if ( $this->mAttribs['rc_user'] > 0 ) {
+                       JobQueueGroup::singleton()->lazyPush( RecentChangesUpdateJob::newCacheUpdateJob() );
+               }
        }
 
        /**
@@ -512,8 +517,10 @@ class RecentChange {
         * @param int $patrol
         * @return RecentChange
         */
-       public static function notifyEdit( $timestamp, &$title, $minor, &$user, $comment, $oldId,
-               $lastTimestamp, $bot, $ip = '', $oldSize = 0, $newSize = 0, $newId = 0, $patrol = 0 ) {
+       public static function notifyEdit(
+               $timestamp, &$title, $minor, &$user, $comment, $oldId, $lastTimestamp,
+               $bot, $ip = '', $oldSize = 0, $newSize = 0, $newId = 0, $patrol = 0
+       ) {
                $rc = new RecentChange;
                $rc->mTitle = $title;
                $rc->mPerformer = $user;
@@ -550,7 +557,13 @@ class RecentChange {
                        'newSize' => $newSize,
                        'pageStatus' => 'changed'
                );
-               $rc->save();
+
+               DeferredUpdates::addCallableUpdate( function() use ( $rc ) {
+                       $rc->save();
+                       if ( $rc->mAttribs['rc_patrolled'] ) {
+                               PatrolLog::record( $rc, true, $rc->getPerformer() );
+                       }
+               } );
 
                return $rc;
        }
@@ -571,8 +584,10 @@ class RecentChange {
         * @param int $patrol
         * @return RecentChange
         */
-       public static function notifyNew( $timestamp, &$title, $minor, &$user, $comment, $bot,
-               $ip = '', $size = 0, $newId = 0, $patrol = 0 ) {
+       public static function notifyNew(
+               $timestamp, &$title, $minor, &$user, $comment, $bot,
+               $ip = '', $size = 0, $newId = 0, $patrol = 0
+       ) {
                $rc = new RecentChange;
                $rc->mTitle = $title;
                $rc->mPerformer = $user;
@@ -609,7 +624,13 @@ class RecentChange {
                        'newSize' => $size,
                        'pageStatus' => 'created'
                );
-               $rc->save();
+
+               DeferredUpdates::addCallableUpdate( function() use ( $rc ) {
+                       $rc->save();
+                       if ( $rc->mAttribs['rc_patrolled'] ) {
+                               PatrolLog::record( $rc, true, $rc->getPerformer() );
+                       }
+               } );
 
                return $rc;
        }
@@ -796,29 +817,6 @@ class RecentChange {
                return ChangesList::showCharacterDifference( $old, $new );
        }
 
-       /**
-        * Purge expired changes from the recentchanges table
-        * @since 1.22
-        */
-       public static function purgeExpiredChanges() {
-               if ( wfReadOnly() ) {
-                       return;
-               }
-
-               $method = __METHOD__;
-               $dbw = wfGetDB( DB_MASTER );
-               $dbw->onTransactionIdle( function () use ( $dbw, $method ) {
-                       global $wgRCMaxAge;
-
-                       $cutoff = $dbw->timestamp( time() - $wgRCMaxAge );
-                       $dbw->delete(
-                               'recentchanges',
-                               array( 'rc_timestamp < ' . $dbw->addQuotes( $cutoff ) ),
-                               $method
-                       );
-               } );
-       }
-
        private static function checkIPAddress( $ip ) {
                global $wgRequest;
                if ( $ip ) {