Avoid circular links updates
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 25 Feb 2006 01:31:07 +0000 (01:31 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 25 Feb 2006 01:31:07 +0000 (01:31 +0000)
includes/JobQueue.php
includes/LinksUpdate.php

index 17ef11d..7cd0878 100644 (file)
@@ -181,7 +181,7 @@ class Job {
 
                $options = new ParserOptions;
                $parserOutput = $wgParser->parse( $revision->getText(), $this->title, $options, true, true, $revision->getId() );
-               $update = new LinksUpdate( $this->title, $parserOutput );
+               $update = new LinksUpdate( $this->title, $parserOutput, false );
                $update->doUpdate();
                return true;
        }
index f1d217b..d74574e 100644 (file)
@@ -21,7 +21,8 @@ class LinksUpdate {
                $mExternals,     # URLs of external links, array key only
                $mCategories,    # Map of category names to sort keys
                $mDb,            # Database connection reference
-               $mOptions;       # SELECT options to be used (array)
+               $mOptions,       # SELECT options to be used (array)
+               $mRecursive;     # Whether to queue jobs for recursive updates
        /**#@-*/
 
        /**
@@ -30,7 +31,7 @@ class LinksUpdate {
         * @param integer $id
         * @param string $title
         */
-       function LinksUpdate( $title, $parserOutput ) {
+       function LinksUpdate( $title, $parserOutput, $recursive = true ) {
                global $wgAntiLockFlags;
 
                if ( $wgAntiLockFlags & ALF_NO_LINK_LOCK ) {
@@ -52,6 +53,7 @@ class LinksUpdate {
                $this->mTemplates = $parserOutput->getTemplates();
                $this->mExternals = $parserOutput->getExternalLinks();
                $this->mCategories = $parserOutput->getCategories();
+               $this->mRecursive = $recursive;
 
        }
 
@@ -92,10 +94,12 @@ class LinksUpdate {
                        $this->getTemplateInsertions( $existing ) );
 
                # Refresh links of all pages including this page
-               $tlto = $this->mTitle->getTemplateLinksTo();
-               if ( count( $tlto ) ) {
-                       require_once( 'JobQueue.php' );
-                       Job::queueLinksJobs( $tlto );
+               if ( $this->mRecursive ) {
+                       $tlto = $this->mTitle->getTemplateLinksTo();
+                       if ( count( $tlto ) ) {
+                               require_once( 'JobQueue.php' );
+                               Job::queueLinksJobs( $tlto );
+                       }
                }
 
                # Category links
@@ -126,10 +130,12 @@ class LinksUpdate {
                $categoryUpdates = array_diff_assoc( $existing, $this->mCategories ) + array_diff_assoc( $this->mCategories, $existing );
 
                # Refresh links of all pages including this page
-               $tlto = $this->mTitle->getTemplateLinksTo();
-               if ( count( $tlto ) ) {
-                       require_once( 'JobQueue.php' );
-                       Job::queueLinksJobs( $tlto );
+               if ( $this->mRecursive ) {
+                       $tlto = $this->mTitle->getTemplateLinksTo();
+                       if ( count( $tlto ) ) {
+                               require_once( 'JobQueue.php' );
+                               Job::queueLinksJobs( $tlto );
+                       }
                }
 
                $this->dumbTableUpdate( 'pagelinks',     $this->getLinkInsertions(),     'pl_from' );