Merge "Avoid "Unable to set value to APCBagOStuff" exceptions"
[lhc/web/wiklou.git] / includes / jobqueue / jobs / RefreshLinksJob.php
index fa3278d..c8a9892 100644 (file)
  * @ingroup JobQueue
  */
 class RefreshLinksJob extends Job {
+       /** @var float Cache parser output when it takes this long to render */
        const PARSE_THRESHOLD_SEC = 1.0;
-
+       /** @var integer Lag safety margin when comparing root job times to last-refresh times */
        const CLOCK_FUDGE = 10;
 
        function __construct( Title $title, array $params ) {
                parent::__construct( 'refreshLinks', $title, $params );
-               // 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)
-               // The second job is ignored by the queue on insertion.
-               // Suppose, many pages use template A, and that template itself uses template B.
-               // An edit to both will first create two base jobs. A clean FIFO queue will have:
-               //              (A base, B base)
-               // When these jobs run, the queue will have per-title and remnant partition jobs:
-               //              (titleX,titleY,titleZ,...,A remnant,titleM,titleN,titleO,...,B remnant)
-               // Some these jobs will be the same, and will automatically be ignored by
-               // the queue upon insertion. Some title jobs will run before the duplicate is
-               // inserted, so the work will still be done twice in those cases. More titles
-               // can be de-duplicated as the remnant jobs continue to be broken down. This
-               // works best when $wgUpdateRowsPerJob, and either the pages have few backlinks
-               // and/or the backlink sets for pages A and B are almost identical.
-               $this->removeDuplicates = !isset( $params['range'] )
-                       && ( !isset( $params['pages'] ) || count( $params['pages'] ) == 1 );
+               // Avoid the overhead of de-duplication when it would be pointless
+               $this->removeDuplicates = (
+                       // Master positions won't match
+                       !isset( $params['masterPos'] ) &&
+                       // Ranges rarely will line up
+                       !isset( $params['range'] ) &&
+                       // Multiple pages per job make matches unlikely
+                       !( isset( $params['pages'] ) && count( $params['pages'] ) != 1 )
+               );
        }
 
        /**
@@ -230,13 +223,10 @@ class RefreshLinksJob extends Job {
                );
 
                foreach ( $updates as $key => $update ) {
-                       // FIXME: move category change RC stuff to a separate update.
-                       // RC entry addition aborts if edits where since made, which is not necessary.
-                       // It's also an SoC violation for links update code to care about RC.
+                       // 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['triggeredRecursive'] ) ) {
-                                       $update->setTriggeredRecursive();
-                               }
                                if ( !empty( $this->params['triggeringUser'] ) ) {
                                        $userInfo = $this->params['triggeringUser'];
                                        if ( $userInfo['userId'] ) {
@@ -247,9 +237,6 @@ class RefreshLinksJob extends Job {
                                        }
                                        $update->setTriggeringUser( $user );
                                }
-                               if ( !empty( $this->params['triggeringRevisionId'] ) ) {
-                                       $update->setRevision( $revision );
-                               }
                        }
                }
 
@@ -273,8 +260,6 @@ class RefreshLinksJob extends Job {
        public function getDeduplicationInfo() {
                $info = parent::getDeduplicationInfo();
                if ( is_array( $info['params'] ) ) {
-                       // Don't let highly unique "masterPos" values ruin duplicate detection
-                       unset( $info['params']['masterPos'] );
                        // For per-pages jobs, the job title is that of the template that changed
                        // (or similar), so remove that since it ruins duplicate detection
                        if ( isset( $info['pages'] ) ) {