* Avoid doing templatelinks query (which can get huge) twice by adding cachupdate...
authorAaron Schulz <aaron@users.mediawiki.org>
Sat, 20 Sep 2008 22:48:55 +0000 (22:48 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Sat, 20 Sep 2008 22:48:55 +0000 (22:48 +0000)
* Don't trigger recursive jobs for nulls edits
* Some whitespace tweaks

includes/Article.php
includes/Import.php
includes/LinksUpdate.php

index 9ffc2f2..78f467a 100644 (file)
@@ -1539,8 +1539,7 @@ class Article {
                        if ( $good ) {
                                # Invalidate cache of this article and all pages using this article
                                # as a template. Partly deferred.
-                               Article::onArticleEdit( $this->mTitle );
-
+                               Article::onArticleEdit( $this->mTitle, false ); // leave templatelinks for editUpdates()
                                # Update links tables, site stats, etc.
                                $this->editUpdates( $text, $summary, $isminor, $now, $revisionId, $changed );
                                $dbw->commit();
@@ -1593,7 +1592,7 @@ class Article {
                        Article::onArticleCreate( $this->mTitle );
 
                        wfRunHooks( 'ArticleInsertComplete', array( &$this, &$user, $text, $summary,
-                        $flags & EDIT_MINOR, null, null, &$flags, $revision ) );
+                               $flags & EDIT_MINOR, null, null, &$flags, $revision ) );
                }
 
                if ( $good && !( $flags & EDIT_DEFER_UPDATES ) ) {
@@ -2701,6 +2700,7 @@ class Article {
        /**
         * Do standard deferred updates after page edit.
         * Update links tables, site stats, search index and message cache.
+        * Purges pages that include this page if the text was changed here.
         * Every 100th edit, prune the recent changes table.
         *
         * @private
@@ -2733,7 +2733,8 @@ class Article {
                }
 
                # Update the links tables
-               $u = new LinksUpdate( $this->mTitle, $editInfo->output );
+               $u = new LinksUpdate( $this->mTitle, $editInfo->output, false );
+               $u->setRecursiveTouch( $changed ); // refresh/invalidate including pages too
                $u->doUpdate();
 
                if( wfRunHooks( 'ArticleEditUpdatesDeleteFromRecentchanges', array( &$this ) ) ) {
@@ -2879,7 +2880,8 @@ class Article {
 
                $r = "\n\t\t\t\t<div id=\"mw-{$infomsg}\">" . wfMsg( $infomsg, $td, $userlinks ) . "</div>\n" .
 
-                    "\n\t\t\t\t<div id=\"mw-revision-nav\">" . $cdel . wfMsg( 'revision-nav', $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff ) . "</div>\n\t\t\t";
+                    "\n\t\t\t\t<div id=\"mw-revision-nav\">" . $cdel . wfMsg( 'revision-nav', $prevdiff, 
+                               $prevlink, $lnk, $curdiff, $nextlink, $nextdiff ) . "</div>\n\t\t\t";
                $wgOut->setSubtitle( $r );
        }
 
@@ -3101,8 +3103,8 @@ class Article {
         * @param $title_obj a title object
         */
 
-       public static function onArticleCreate($title) {
-               # The talk page isn't in the regular link tables, so we need to update manually:
+       public static function onArticleCreate( $title ) {
+               # Update existence markers on article/talk tabs...
                if ( $title->isTalkPage() ) {
                        $other = $title->getSubjectPage();
                } else {
@@ -3118,8 +3120,7 @@ class Article {
 
        public static function onArticleDelete( $title ) {
                global $wgUseFileCache, $wgMessageCache;
-
-               // Update existence markers on article/talk tabs...
+               # Update existence markers on article/talk tabs...
                if( $title->isTalkPage() ) {
                        $other = $title->getSubjectPage();
                } else {
@@ -3156,11 +3157,12 @@ class Article {
        /**
         * Purge caches on page update etc
         */
-       static function onArticleEdit( $title ) {
+       public static function onArticleEdit( $title, $touchTemplates = true ) {
                global $wgDeferredUpdateList, $wgUseFileCache;
 
                // Invalidate caches of articles which include this page
-               $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'templatelinks' );
+               if( $touchTemplates )
+                       $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'templatelinks' );
 
                // Invalidate the caches of all pages which redirect here
                $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'redirect' );
index a5bd182..b8db934 100644 (file)
@@ -219,7 +219,7 @@ class WikiRevision {
 
                } elseif( $changed ) {
                        wfDebug( __METHOD__ . ": running onArticleEdit\n" );
-                       Article::onArticleEdit( $this->title );
+                       Article::onArticleEdit( $this->title, false ); // leave templatelinks for editUpdates()
 
                        wfDebug( __METHOD__ . ": running edit updates\n" );
                        $article->editUpdates(
index 6088fcc..4b8f6d6 100644 (file)
@@ -20,7 +20,8 @@ class LinksUpdate {
                $mProperties,    //!< Map of arbitrary name to value
                $mDb,            //!< Database connection reference
                $mOptions,       //!< SELECT options to be used (array)
-               $mRecursive;     //!< Whether to queue jobs for recursive updates
+               $mRecursive,     //!< Whether to queue jobs for recursive updates
+               $mTouchTmplLinks; //!< Whether to queue HTMLCacheUpdate jobs IF recursive
        /**@}}*/
 
        /**
@@ -67,14 +68,24 @@ class LinksUpdate {
                }
 
                $this->mRecursive = $recursive;
+               $this->mTouchTmplLinks = false;
 
                wfRunHooks( 'LinksUpdateConstructed', array( &$this ) );
        }
+       
+       /**
+        * Invalidate HTML cache of pages that include this page?
+        */
+       public function setRecursiveTouch( $val ) {
+               $this->mTouchTmplLinks = (bool)$val;
+               if( $val ) // Cannot invalidate without queueRecursiveJobs()
+                       $this->mRecursive = true;
+       }
 
        /**
         * Update link tables with outgoing links from an updated article
         */
-       function doUpdate() {
+       public function doUpdate() {
                global $wgUseDumbLinkUpdate;
 
                wfRunHooks( 'LinksUpdate', array( &$this ) );
@@ -229,7 +240,11 @@ class LinksUpdate {
                                'end' => ( $id !== false ? $id - 1 : false ),
                        );
                        $jobs[] = new RefreshLinksJob2( $this->mTitle, $params );
-
+                       # Hit page caches while we're at it if set to do so...
+                       if( $this->mTouchTmplLinks ) {
+                               $params['table'] = 'templatelinks';
+                               $jobs[] = new HTMLCacheUpdateJob( $this->mTitle, $params );
+                       }
                        $start = $id;
                } while ( $start );