r87109 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87108‎ | r87109 | r87110 >
Date:00:46, 29 April 2011
Author:reedy
Status:deferred
Tags:
Comment:
Merge r80802
Modified paths:
  • /branches/iwtransclusion/phase3v2 (modified) (history)
  • /branches/iwtransclusion/phase3v2/includes/Article.php (modified) (history)
  • /branches/iwtransclusion/phase3v2/includes/BacklinkCache.php (modified) (history)
  • /branches/iwtransclusion/phase3v2/includes/DefaultSettings.php (modified) (history)
  • /branches/iwtransclusion/phase3v2/includes/Linker.php (modified) (history)
  • /branches/iwtransclusion/phase3v2/includes/cache/HTMLCacheUpdate.php (modified) (history)
  • /branches/iwtransclusion/phase3v2/includes/interwiki/Interwiki.php (modified) (history)

Diff [purge]

Index: branches/iwtransclusion/phase3v2/includes/DefaultSettings.php
@@ -2938,13 +2938,35 @@
29392939 $wgPreprocessorCacheThreshold = 1000;
29402940
29412941 /**
2942 - * Enable interwiki transcluding. Only when iw_trans=1.
 2942+ * Enable interwiki transcluding. Only when iw_trans=1 in the interwiki table.
 2943+ * If the interwiki prefix is associated with a wiki ID in the interwiki table,
 2944+ * then the distant templates will be retrieved in the distant DB. If there is
 2945+ * no wiki ID but a API URL for that prefix, the distant templates will be
 2946+ * retrieved using the API and cached in memcached.
29432947 */
2944 -$wgEnableScaryTranscluding = false;
 2948+$wgEnableInterwikiTranscluding = false;
29452949
29462950 /**
2947 - * Expiry time for interwiki transclusion
 2951+ * If $wgEnableInterwikiTranscluding is set to true and if an interwiki prefix
 2952+ * is associated with a wiki ID, then, this option should be set to true to
 2953+ * enable the cache invalidation of the distant pages when the local templates
 2954+ * are edited and also to display the list of the distant templates used by
 2955+ * the local pages. Enabling this requires to set up a global shared database
 2956+ * (see next option $wgGlobalDatabase).
29482957 */
 2958+$wgEnableInterwikiTemplatesTracking = false;
 2959+
 2960+/**
 2961+ * If $wgEnableInterwikiTemplatesTracking is set to true, this option should
 2962+ * contain the wiki ID of the database that hosts the globaltemplatelinks table.
 2963+ */
 2964+$wgGlobalDatabase = '';
 2965+
 2966+/**
 2967+ * If $wgEnableInterwikiTranscluding is set to true and if an interwiki
 2968+ * prefix is associated with an API URL and no wiki ID, this will be
 2969+ * the expiry time for the transcluded templates cached in memcached.
 2970+ */
29492971 $wgTranscludeCacheExpiry = 3600;
29502972
29512973 /** @} */ # end of parser settings }
Index: branches/iwtransclusion/phase3v2/includes/Article.php
@@ -4007,6 +4007,10 @@
40084008
40094009 // Invalidate caches of articles which include this page
40104010 $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'templatelinks' );
 4011+
 4012+ // Invalidate caches of distant articles which transclude this page
 4013+ $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'globaltemplatelinks' );
 4014+ wfDoUpdates();
40114015
40124016 // Invalidate the caches of all pages which redirect here
40134017 $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'redirect' );
@@ -4174,7 +4178,7 @@
41754179 }
41764180
41774181 $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase );
4178 - $res = $dbr->select( array( 'globaltemplatelinks' ),
 4182+ $res = $dbr->select( 'globaltemplatelinks',
41794183 array( 'gtl_to_prefix', 'gtl_to_namespace', 'gtl_to_title' ),
41804184 array( 'gtl_from_wiki' => wfWikiID( ), 'gtl_from_page' => $id ),
41814185 __METHOD__ );
@@ -4184,10 +4188,8 @@
41854189 $result[] = Title::makeTitle( $row->gtl_to_namespace, $row->gtl_to_title, null, $row->gtl_to_prefix );
41864190 }
41874191 }
4188 -
4189 - $dbr->freeResult( $res );
41904192 }
4191 -
 4193+
41924194 return $result;
41934195 }
41944196
Index: branches/iwtransclusion/phase3v2/includes/Linker.php
@@ -1594,12 +1594,6 @@
15951595
15961596 $outText = '';
15971597 if ( count( $templates ) > 0 ) {
1598 - # Do a batch existence check
1599 - $batch = new LinkBatch;
1600 - foreach( $templates as $title ) {
1601 - $batch->addObj( $title );
1602 - }
1603 - $batch->execute();
16041598
16051599 # Construct the HTML
16061600 $outText = '<div class="mw-templatesUsedExplanation">';
Index: branches/iwtransclusion/phase3v2/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/phase3v2/includes/interwiki/Interwiki.php
___________________________________________________________________
Modified: svn:mergeinfo
1617 Merged /branches/iwtransclusion/phase3/includes/interwiki/Interwiki.php:r70802
Index: branches/iwtransclusion/phase3v2/includes/BacklinkCache.php
@@ -173,6 +173,27 @@
174174 }
175175
176176 /**
 177+ * Get the distant backtemplatelinks for the table globaltemplatelinks. Cached in process memory only.
 178+ * @param $table String
 179+ * @param $startId Integer or false
 180+ * @param $endId Integer or false
 181+ * @return TitleArray
 182+ */
 183+ public function getDistantTemplateLinks( ) {
 184+ global $wgGlobalDatabase, $wgLocalInterwiki;
 185+
 186+ $dbr = $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase );
 187+ $res = $dbr->select(
 188+ array( 'globaltemplatelinks' ),
 189+ array( 'gtl_from_wiki', 'gtl_from_page' ),
 190+ array( 'gtl_to_prefix' => $wgLocalInterwiki, 'gtl_to_title' => $this->title->getDBkey( ) ),
 191+ __METHOD__,
 192+ 'GROUP BY gtl_from_wiki'
 193+ );
 194+ return $res;
 195+ }
 196+
 197+ /**
177198 * Get the field name prefix for a given table
178199 * @param $table String
179200 */
@@ -183,6 +204,7 @@
184205 'categorylinks' => 'cl',
185206 'templatelinks' => 'tl',
186207 'redirect' => 'rd',
 208+ 'globaltemplatelinks' => 'gtl',
187209 );
188210
189211 if ( isset( $prefixes[$table] ) ) {
Index: branches/iwtransclusion/phase3v2/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 /**
@@ -204,7 +215,35 @@
205216 }
206217 }
207218 }
208 -
 219+
 220+ /**
 221+ * Invalidate an array of distant pages, given the wiki ID and page ID of those pages
 222+ */
 223+ protected function invalidateDistantTitles( $distantPageArray ) {
 224+ global $wgUseFileCache, $wgUseSquid, $wgLocalInterwiki;
 225+
 226+ $pagesByWiki = array();
 227+ foreach ( $distantPageArray as $row ) {
 228+ $wikiid = $row->gtl_from_wiki;
 229+ if( !isset( $pagesByWiki[$wikiid] ) ) {
 230+ $pagesByWiki[$wikiid] = array();
 231+ }
 232+ $pagesByWiki[$wikiid][] = $row->gtl_from_page;
 233+ }
 234+
 235+ foreach ( $pagesByWiki as $wikiid => $pages ) {
 236+ $dbw = wfGetDB( DB_MASTER, array( ), $wikiid );
 237+ $timestamp = $dbw->timestamp();
 238+ $batches = array_chunk( $pages, $this->mRowsPerQuery );
 239+ foreach ( $batches as $batch ) {
 240+ $dbw->update( 'page',
 241+ array( 'page_touched' => $timestamp ),
 242+ array( 'page_id IN (' . $dbw->makeList( $batch ) . ')' ),
 243+ __METHOD__
 244+ );
 245+ }
 246+ }
 247+ }
209248 }
210249
211250 /**
Property changes on: branches/iwtransclusion/phase3v2
___________________________________________________________________
Modified: svn:mergeinfo
212251 Merged /branches/iwtransclusion/phase3:r70802-70803

Follow-up revisions

RevisionCommit summaryAuthorDate
r92994Merge r87109, merge of r70802reedy18:18, 24 July 2011

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

Status & tagging log