On edit, purge the cache of pages redirecting to the page in question. Obvious perhap...
authorTim Starling <tstarling@users.mediawiki.org>
Thu, 17 Jan 2008 12:31:54 +0000 (12:31 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Thu, 17 Jan 2008 12:31:54 +0000 (12:31 +0000)
includes/Article.php
includes/HTMLCacheUpdate.php

index 595a690..27a57f3 100644 (file)
@@ -2968,9 +2968,11 @@ class Article {
                global $wgDeferredUpdateList, $wgUseFileCache;
 
                // Invalidate caches of articles which include this page
-               $update = new HTMLCacheUpdate( $title, 'templatelinks' );
-               $wgDeferredUpdateList[] = $update;
+               $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'templatelinks' );
 
+               // Invalidate the caches of all pages which redirect here
+               $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'redirect' );
+               
                # Purge squid for this page only
                $title->purgeSquid();
 
index 260439b..050005d 100644 (file)
@@ -25,6 +25,7 @@ class HTMLCacheUpdate
 {
        public $mTitle, $mTable, $mPrefix;
        public $mRowsPerJob, $mRowsPerQuery;
+       public $mResult;
 
        function __construct( $titleTo, $table ) {
                global $wgUpdateRowsPerJob, $wgUpdateRowsPerQuery;
@@ -40,15 +41,14 @@ class HTMLCacheUpdate
                $cond = $this->getToCondition();
                $dbr = wfGetDB( DB_SLAVE );
                $res = $dbr->select( $this->mTable, $this->getFromField(), $cond, __METHOD__ );
-               $resWrap = new ResultWrapper( $dbr, $res );
+               $this->mResult = $res;
                if ( $dbr->numRows( $res ) != 0 ) {
                        if ( $dbr->numRows( $res ) > $this->mRowsPerJob ) {
-                               $this->insertJobs( $resWrap );
+                               $this->insertJobs( $res );
                        } else {
-                               $this->invalidateIDs( $resWrap );
+                               $this->invalidateIDs( $res );
                        }
                }
-               $dbr->freeResult( $res );
        }
 
        function insertJobs( ResultWrapper $res ) {
@@ -87,6 +87,7 @@ class HTMLCacheUpdate
                        'imagelinks' => 'il',
                        'categorylinks' => 'cl',
                        'templatelinks' => 'tl',
+                       'redirect' => 'rd',
                        
                        # Not needed
                        # 'externallinks' => 'el',
@@ -107,16 +108,14 @@ class HTMLCacheUpdate
        }
 
        function getToCondition() {
+               $prefix = $this->getPrefix();
                switch ( $this->mTable ) {
                        case 'pagelinks':
-                               return array( 
-                                       'pl_namespace' => $this->mTitle->getNamespace(),
-                                       'pl_title' => $this->mTitle->getDBkey()
-                               );
                        case 'templatelinks':
-                               return array(
-                                       'tl_namespace' => $this->mTitle->getNamespace(),
-                                       'tl_title' => $this->mTitle->getDBkey()
+                       case 'redirect':
+                               return array( 
+                                       "{$prefix}_namespace" => $this->mTitle->getNamespace(),
+                                       "{$prefix}_title" => $this->mTitle->getDBkey()
                                );
                        case 'imagelinks':
                                return array( 'il_to' => $this->mTitle->getDBkey() );
@@ -218,7 +217,6 @@ class HTMLCacheUpdateJob extends Job {
                $dbr = wfGetDB( DB_SLAVE );
                $res = $dbr->select( $this->table, $fromField, $conds, __METHOD__ );
                $update->invalidateIDs( new ResultWrapper( $dbr, $res ) );
-               $dbr->freeResult( $res );
 
                return true;
        }