From: Tim Starling Date: Thu, 17 Jan 2008 12:31:54 +0000 (+0000) Subject: On edit, purge the cache of pages redirecting to the page in question. Obvious perhap... X-Git-Tag: 1.31.0-rc.0~49940 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=5f2826012b40c1932569b8aa4e98864aab9077c5;p=lhc%2Fweb%2Fwiklou.git On edit, purge the cache of pages redirecting to the page in question. Obvious perhaps, but apparently never done. --- diff --git a/includes/Article.php b/includes/Article.php index 595a690fba..27a57f350e 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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(); diff --git a/includes/HTMLCacheUpdate.php b/includes/HTMLCacheUpdate.php index 260439b233..050005dd1d 100644 --- a/includes/HTMLCacheUpdate.php +++ b/includes/HTMLCacheUpdate.php @@ -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; }