r92994 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92993‎ | r92994 | r92995 >
Date:18:18, 24 July 2011
Author:reedy
Status:deferred
Tags:
Comment:
Merge r87109, merge of r70802
Modified paths:
  • /branches/iwtransclusion/phase3v3/includes/BacklinkCache.php (modified) (history)
  • /branches/iwtransclusion/phase3v3/includes/DefaultSettings.php (modified) (history)
  • /branches/iwtransclusion/phase3v3/includes/Linker.php (modified) (history)
  • /branches/iwtransclusion/phase3v3/includes/WikiPage.php (modified) (history)
  • /branches/iwtransclusion/phase3v3/includes/cache/HTMLCacheUpdate.php (modified) (history)
  • /branches/iwtransclusion/phase3v3/includes/interwiki/Interwiki.php (modified) (history)

Diff [purge]

Index: branches/iwtransclusion/phase3v3/includes/Linker.php
@@ -1659,12 +1659,6 @@
16601660
16611661 $outText = '';
16621662 if ( count( $templates ) > 0 ) {
1663 - # Do a batch existence check
1664 - $batch = new LinkBatch;
1665 - foreach( $templates as $title ) {
1666 - $batch->addObj( $title );
1667 - }
1668 - $batch->execute();
16691663
16701664 # Construct the HTML
16711665 $outText = '<div class="mw-templatesUsedExplanation">';
Index: branches/iwtransclusion/phase3v3/includes/interwiki/Interwiki.php
@@ -9,6 +9,7 @@
1010 * All information is loaded on creation when called by Interwiki::fetch( $prefix ).
1111 * All work is done on slave, because this should *never* change (except during
1212 * schema updates etc, which aren't wiki-related)
 13+ * This class also contains the functions that allow interwiki templates transclusion.
1314 */
1415 class Interwiki {
1516
Property changes on: branches/iwtransclusion/phase3v3/includes/interwiki/Interwiki.php
___________________________________________________________________
Modified: svn:mergeinfo
1617 Merged /branches/iwtransclusion/phase3/includes/interwiki/Interwiki.php:r70802
1718 Merged /branches/iwtransclusion/phase3v2/includes/interwiki/Interwiki.php:r87109
Index: branches/iwtransclusion/phase3v3/includes/BacklinkCache.php
@@ -175,6 +175,27 @@
176176 }
177177
178178 /**
 179+ * Get the distant backtemplatelinks for the table globaltemplatelinks. Cached in process memory only.
 180+ * @param $table String
 181+ * @param $startId Integer or false
 182+ * @param $endId Integer or false
 183+ * @return TitleArray
 184+ */
 185+ public function getDistantTemplateLinks( ) {
 186+ global $wgGlobalDatabase, $wgLocalInterwiki;
 187+
 188+ $dbr = $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase );
 189+ $res = $dbr->select(
 190+ array( 'globaltemplatelinks' ),
 191+ array( 'gtl_from_wiki', 'gtl_from_page' ),
 192+ array( 'gtl_to_prefix' => $wgLocalInterwiki, 'gtl_to_title' => $this->title->getDBkey( ) ),
 193+ __METHOD__,
 194+ 'GROUP BY gtl_from_wiki'
 195+ );
 196+ return $res;
 197+ }
 198+
 199+ /**
179200 * Get the field name prefix for a given table
180201 * @param $table String
181202 */
@@ -185,6 +206,7 @@
186207 'categorylinks' => 'cl',
187208 'templatelinks' => 'tl',
188209 'redirect' => 'rd',
 210+ 'globaltemplatelinks' => 'gtl',
189211 );
190212
191213 if ( isset( $prefixes[$table] ) ) {
Index: branches/iwtransclusion/phase3v3/includes/cache/HTMLCacheUpdate.php
@@ -51,6 +51,16 @@
5252 return;
5353 }
5454
 55+ if ( $this->mTable === 'globaltemplatelinks' ) {
 56+ global $wgEnableInterwikiTemplatesTracking;
 57+
 58+ if ( $wgEnableInterwikiTemplatesTracking ) {
 59+ $distantPageArray = $this->mCache->getDistantTemplateLinks( 'globaltemplatelinks' );
 60+ $this->invalidateDistantTitles( $distantPageArray );
 61+ }
 62+ return;
 63+ }
 64+
5565 # Get an estimate of the number of rows from the BacklinkCache
5666 $numRows = $this->mCache->getNumLinks( $this->mTable );
5767 if ( $numRows > $this->mRowsPerJob * 2 ) {
@@ -68,6 +78,7 @@
6979 $this->invalidateTitles( $titleArray );
7080 }
7181 }
 82+ wfRunHooks( 'HTMLCacheUpdate::doUpdate', array($this->mTitle) );
7283 }
7384
7485 /**
@@ -197,7 +208,35 @@
198209 }
199210 }
200211 }
201 -
 212+
 213+ /**
 214+ * Invalidate an array of distant pages, given the wiki ID and page ID of those pages
 215+ */
 216+ protected function invalidateDistantTitles( $distantPageArray ) {
 217+ global $wgUseFileCache, $wgUseSquid, $wgLocalInterwiki;
 218+
 219+ $pagesByWiki = array();
 220+ foreach ( $distantPageArray as $row ) {
 221+ $wikiid = $row->gtl_from_wiki;
 222+ if( !isset( $pagesByWiki[$wikiid] ) ) {
 223+ $pagesByWiki[$wikiid] = array();
 224+ }
 225+ $pagesByWiki[$wikiid][] = $row->gtl_from_page;
 226+ }
 227+
 228+ foreach ( $pagesByWiki as $wikiid => $pages ) {
 229+ $dbw = wfGetDB( DB_MASTER, array( ), $wikiid );
 230+ $timestamp = $dbw->timestamp();
 231+ $batches = array_chunk( $pages, $this->mRowsPerQuery );
 232+ foreach ( $batches as $batch ) {
 233+ $dbw->update( 'page',
 234+ array( 'page_touched' => $timestamp ),
 235+ array( 'page_id IN (' . $dbw->makeList( $batch ) . ')' ),
 236+ __METHOD__
 237+ );
 238+ }
 239+ }
 240+ }
202241 }
203242
204243 /**
Index: branches/iwtransclusion/phase3v3/includes/WikiPage.php
@@ -2254,6 +2254,10 @@
22552255
22562256 // Invalidate caches of articles which include this page
22572257 $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'templatelinks' );
 2258+
 2259+ // Invalidate caches of distant articles which transclude this page
 2260+ $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'globaltemplatelinks' );
 2261+ wfDoUpdates();
22582262
22592263 // Invalidate the caches of all pages which redirect here
22602264 $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'redirect' );
@@ -2315,7 +2319,7 @@
23162320 }
23172321
23182322 $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase );
2319 - $res = $dbr->select( array( 'globaltemplatelinks' ),
 2323+ $res = $dbr->select( 'globaltemplatelinks',
23202324 array( 'gtl_to_prefix', 'gtl_to_namespace', 'gtl_to_title' ),
23212325 array( 'gtl_from_wiki' => wfWikiID( ), 'gtl_from_page' => $id ),
23222326 __METHOD__ );
@@ -2325,8 +2329,6 @@
23262330 $result[] = Title::makeTitle( $row->gtl_to_namespace, $row->gtl_to_title, null, $row->gtl_to_prefix );
23272331 }
23282332 }
2329 -
2330 - $dbr->freeResult( $res );
23312333 }
23322334
23332335 return $result;
Index: branches/iwtransclusion/phase3v3/includes/DefaultSettings.php
@@ -2943,13 +2943,35 @@
29442944 $wgPreprocessorCacheThreshold = 1000;
29452945
29462946 /**
2947 - * Enable interwiki transcluding. Only when iw_trans=1.
 2947+ * Enable interwiki transcluding. Only when iw_trans=1 in the interwiki table.
 2948+ * If the interwiki prefix is associated with a wiki ID in the interwiki table,
 2949+ * then the distant templates will be retrieved in the distant DB. If there is
 2950+ * no wiki ID but a API URL for that prefix, the distant templates will be
 2951+ * retrieved using the API and cached in memcached.
29482952 */
2949 -$wgEnableScaryTranscluding = false;
 2953+$wgEnableInterwikiTranscluding = false;
29502954
29512955 /**
2952 - * Expiry time for interwiki transclusion
 2956+ * If $wgEnableInterwikiTranscluding is set to true and if an interwiki prefix
 2957+ * is associated with a wiki ID, then, this option should be set to true to
 2958+ * enable the cache invalidation of the distant pages when the local templates
 2959+ * are edited and also to display the list of the distant templates used by
 2960+ * the local pages. Enabling this requires to set up a global shared database
 2961+ * (see next option $wgGlobalDatabase).
29532962 */
 2963+$wgEnableInterwikiTemplatesTracking = false;
 2964+
 2965+/**
 2966+ * If $wgEnableInterwikiTemplatesTracking is set to true, this option should
 2967+ * contain the wiki ID of the database that hosts the globaltemplatelinks table.
 2968+ */
 2969+$wgGlobalDatabase = '';
 2970+
 2971+/**
 2972+ * If $wgEnableInterwikiTranscluding is set to true and if an interwiki
 2973+ * prefix is associated with an API URL and no wiki ID, this will be
 2974+ * the expiry time for the transcluded templates cached in memcached.
 2975+ */
29542976 $wgTranscludeCacheExpiry = 3600;
29552977
29562978 /** @} */ # end of parser settings }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r70802Fix remarks about r70764; invalidate the cache of the distant pages when the ...peter1709:11, 10 August 2010
r87109Merge r80802reedy00:46, 29 April 2011

Status & tagging log