RefreshLinksJob: Restore LinksUpdate::setTriggeringUser() call
authorKunal Mehta <legoktm@member.fsf.org>
Thu, 17 Dec 2015 18:50:53 +0000 (10:50 -0800)
committerKunal Mehta <legoktm@member.fsf.org>
Thu, 17 Dec 2015 18:50:53 +0000 (10:50 -0800)
This partially reverts 22476baa85bdb70c60, as the setTriggeringUser()
call that was removed was being used by Echo to be able to determine
which user caused a LinksUpdate to be triggered.

Bug: T121780
Change-Id: I62732032a6b74f17b5ae6a2497fa519f9ff38d4f

includes/jobqueue/jobs/RefreshLinksJob.php

index 183c1ee..c8a9892 100644 (file)
@@ -222,6 +222,24 @@ class RefreshLinksJob extends Job {
                        $parserOutput
                );
 
+               foreach ( $updates as $key => $update ) {
+                       // FIXME: This code probably shouldn't be here?
+                       // Needed by things like Echo notifications which need
+                       // to know which user caused the links update
+                       if ( $update instanceof LinksUpdate ) {
+                               if ( !empty( $this->params['triggeringUser'] ) ) {
+                                       $userInfo = $this->params['triggeringUser'];
+                                       if ( $userInfo['userId'] ) {
+                                               $user = User::newFromId( $userInfo['userId'] );
+                                       } else {
+                                               // Anonymous, use the username
+                                               $user = User::newFromName( $userInfo['userName'], false );
+                                       }
+                                       $update->setTriggeringUser( $user );
+                               }
+                       }
+               }
+
                $latestNow = $page->lockAndGetLatest();
                if ( !$latestNow || $revision->getId() != $latestNow ) {
                        // Do not clobber over newer updates with older ones. If all jobs where FIFO and