Merge "Add help link to Special:Search"
[lhc/web/wiklou.git] / includes / jobqueue / jobs / RefreshLinksJob.php
index 3a83cb8..26f4520 100644 (file)
@@ -41,10 +41,6 @@ class RefreshLinksJob extends Job {
 
        function __construct( Title $title, array $params ) {
                parent::__construct( 'refreshLinks', $title, $params );
-               // A separate type is used just for cascade-protected backlinks
-               if ( !empty( $this->params['prioritize'] ) ) {
-                       $this->command .= 'Prioritized';
-               }
                // Base backlink update jobs and per-title update jobs can be de-duplicated.
                // If template A changes twice before any jobs run, a clean queue will have:
                //              (A base, A base)
@@ -64,6 +60,30 @@ class RefreshLinksJob extends Job {
                        && ( !isset( $params['pages'] ) || count( $params['pages'] ) == 1 );
        }
 
+       /**
+        * @param Title $title
+        * @param array $params
+        * @return RefreshLinksJob
+        */
+       public static function newPrioritized( Title $title, array $params ) {
+               $job = new self( $title, $params );
+               $job->command = 'refreshLinksPrioritized';
+
+               return $job;
+       }
+
+       /**
+        * @param Title $title
+        * @param array $params
+        * @return RefreshLinksJob
+        */
+       public static function newDynamic( Title $title, array $params ) {
+               $job = new self( $title, $params );
+               $job->command = 'refreshLinksDynamic';
+
+               return $job;
+       }
+
        function run() {
                global $wgUpdateRowsPerJob;
 
@@ -195,8 +215,20 @@ class RefreshLinksJob extends Job {
                $updates = $content->getSecondaryDataUpdates(
                        $title, null, !empty( $this->params['useRecursiveLinksUpdate'] ), $parserOutput );
                foreach ( $updates as $key => $update ) {
-                       if ( $update instanceof LinksUpdate && isset( $this->params['triggeredRecursive'] ) ) {
-                               $update->setTriggeredRecursive();
+                       if ( $update instanceof LinksUpdate ) {
+                               if ( isset( $this->params['triggeredRecursive'] ) ) {
+                                       $update->setTriggeredRecursive();
+                               }
+                               if ( isset( $this->params['triggeringUser'] ) && $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 );
+                               }
                        }
                }