r87115 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87114‎ | r87115 | r87116 >
Date:01:04, 29 April 2011
Author:reedy
Status:deferred
Tags:
Comment:
Merge r76200

Hmm. That was a *LOT* simpler
Modified paths:
  • /branches/iwtransclusion/phase3v2 (modified) (history)
  • /branches/iwtransclusion/phase3v2/includes/BacklinkCache.php (modified) (history)
  • /branches/iwtransclusion/phase3v2/includes/GlobalUsageQuery.php (modified) (history)
  • /branches/iwtransclusion/phase3v2/includes/LinksUpdate.php (modified) (history)
  • /branches/iwtransclusion/phase3v2/includes/Title.php (modified) (history)
  • /branches/iwtransclusion/phase3v2/includes/cache/HTMLCacheUpdate.php (modified) (history)
  • /branches/iwtransclusion/phase3v2/includes/specials/SpecialGlobalFileUsage.php (modified) (history)
  • /branches/iwtransclusion/phase3v2/maintenance/archives/patch-globalinterwiki.sql (added) (history)
  • /branches/iwtransclusion/phase3v2/maintenance/archives/patch-globalnamespaces.sql (added) (history)
  • /branches/iwtransclusion/phase3v2/maintenance/archives/patch-globaltemplatelinks.sql (modified) (history)

Diff [purge]

Index: branches/iwtransclusion/phase3v2/maintenance/archives/patch-globaltemplatelinks.sql
@@ -9,9 +9,10 @@
1010 -- The page ID of the calling page on the remote wiki
1111 gtl_from_page int unsigned NOT NULL,
1212
13 - -- The namespace name of the calling page on the remote wiki
 13+ -- The namespace of the calling page on the remote wiki
1414 -- Needed for display purposes, since the foreign namespace ID doesn't necessarily match a local one
15 - gtl_from_namespace varchar(255) NOT NULL,
 15+ -- The link between the namespace and the namespace name is made by the globalnamespaces table
 16+ gtl_from_namespace int NOT NULL,
1617
1718 -- The title of the calling page on the remote wiki
1819 -- Needed for display purposes
Index: branches/iwtransclusion/phase3v2/maintenance/archives/patch-globalnamespaces.sql
@@ -0,0 +1,14 @@
 2+-- Table listing distant wiki namespace texts.
 3+CREATE TABLE /*_*/globalnamespaces (
 4+ -- The wiki ID of the remote wiki
 5+ gn_wiki varchar(64) NOT NULL,
 6+
 7+ -- The namespace ID of the transcluded page on that wiki
 8+ gn_namespace int NOT NULL,
 9+
 10+ -- The namespace text of transcluded page
 11+ -- Needed for display purposes, since the local namespace ID doesn't necessarily match a distant one
 12+ gn_namespacetext varchar(255) NOT NULL
 13+
 14+) /*$wgDBTableOptions*/;
 15+CREATE UNIQUE INDEX /*i*/gn_index ON /*_*/globalnamespaces (gn_wiki, gn_namespace, gn_namespacetext);
Index: branches/iwtransclusion/phase3v2/maintenance/archives/patch-globalinterwiki.sql
@@ -0,0 +1,10 @@
 2+-- Table associating distant wiki IDs with their interwiki prefixes.
 3+CREATE TABLE /*_*/globalinterwiki (
 4+ -- The wiki ID of the wiki
 5+ giw_wikiid varchar(64) NOT NULL,
 6+
 7+ -- The interwiki prefix of that wiki
 8+ giw_prefix varchar(32) NOT NULL
 9+
 10+) /*$wgDBTableOptions*/;
 11+CREATE UNIQUE INDEX /*i*/giw_index ON /*_*/globalinterwiki (giw_wikiid, giw_prefix);
Index: branches/iwtransclusion/phase3v2/includes/LinksUpdate.php
@@ -352,6 +352,39 @@
353353 $this->mDb->insert( $table, $insertions, __METHOD__, 'IGNORE' );
354354 }
355355 }
 356+
 357+ /**
 358+ * Update a shared table by doing a delete query then an insert query
 359+ * @private
 360+ */
 361+ function incrSharedTableUpdate( $table, $prefix, $deletions, $insertions ) {
 362+ global $wgEnableInterwikiTemplatesTracking, $wgGlobalDatabase;
 363+
 364+ if ( $wgEnableInterwikiTemplatesTracking && $wgGlobalDatabase ) {
 365+ $dbw = wfGetDB( DB_MASTER, array(), $wgGlobalDatabase );
 366+ $where = array( "{$prefix}_from_wiki" => wfWikiID( ),
 367+ "{$prefix}_from_page" => $this->mId
 368+ );
 369+ $baseKey = "{$prefix}_to_prefix";
 370+ $middleKey = "{$prefix}_to_namespace";
 371+
 372+ $clause = $dbw->makeWhereFrom3d( $deletions, $baseKey, $middleKey, "{$prefix}_to_title" );
 373+ if ( $clause ) {
 374+ $where[] = $clause;
 375+ } else {
 376+ $where = false;
 377+ }
 378+
 379+ if ( $where ) {
 380+ $dbw->delete( $table, $where, __METHOD__ );
 381+ }
 382+ if ( count( $insertions ) ) {
 383+ $dbw->insert( 'globaltemplatelinks', $insertions['globaltemplatelinks'], __METHOD__, 'IGNORE' );
 384+ $dbw->insert( 'globalnamespaces', $insertions['globalnamespaces'], __METHOD__, 'IGNORE' );
 385+ $dbw->insert( 'globalinterwiki', $insertions['globalinterwiki'], __METHOD__, 'IGNORE' );
 386+ }
 387+ }
 388+ }
356389
357390
358391 /**
@@ -393,6 +426,37 @@
394427 return $arr;
395428 }
396429
 430+ $arr = array();
 431+ foreach( $this->mDistantTemplates as $prefix => $templatesToNS ) {
 432+ foreach( $templatesToNS as $ns => $dbkeys ) {
 433+ $diffs = isset( $existing[$prefix] ) && isset( $existing[$prefix][$ns] ) ? array_diff_key( $dbkeys, $existing[$prefix][$ns] ) : $dbkeys;
 434+ $interwiki = Interwiki::fetch( $prefix );
 435+ $wikiid = $interwiki->getWikiID( );
 436+ foreach ( $diffs as $dbk => $id ) {
 437+ $arr['globaltemplatelinks'][] = array(
 438+ 'gtl_from_wiki' => wfWikiID( ),
 439+ 'gtl_from_page' => $this->mId,
 440+ 'gtl_from_namespace' => $this->mTitle->getNamespace(),
 441+ 'gtl_from_title' => $this->mTitle->getText(),
 442+ 'gtl_to_prefix' => $prefix,
 443+ 'gtl_to_namespace' => $ns,
 444+ 'gtl_to_title' => $dbk
 445+ );
 446+ $arr['globalinterwiki'][] = array(
 447+ 'giw_wikiid' => $wikiid,
 448+ 'giw_prefix' => $prefix
 449+ );
 450+ $arr['globalnamespaces'][] = array(
 451+ 'gn_wiki' => wfWikiID( ),
 452+ 'gn_namespace' => $this->mTitle->getNamespace(),
 453+ 'gn_namespacetext' => $this->mTitle->getNsText(),
 454+ );
 455+ }
 456+ }
 457+ }
 458+ return $arr;
 459+ }
 460+
397461 /**
398462 * Get an array of image insertions
399463 * Skips the names specified in $existing
Index: branches/iwtransclusion/phase3v2/includes/BacklinkCache.php
@@ -181,10 +181,12 @@
182182
183183 $dbr = $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase );
184184 $res = $dbr->select(
185 - array( 'globaltemplatelinks' ),
186 - array( 'gtl_from_wiki', 'gtl_from_page' ),
 185+ array( 'globaltemplatelinks', 'globalinterwiki' ),
 186+ array( 'gtl_from_wiki', 'gtl_from_page', 'gtl_from_title', 'giw_prefix' ),
187187 array( 'gtl_to_prefix' => $wgLocalInterwiki, 'gtl_to_title' => $this->title->getDBkey( ) ),
188 - __METHOD__
 188+ __METHOD__,
 189+ null,
 190+ array( 'gtl_from_wiki = giw_wikiid' )
189191 );
190192 return $res;
191193 }
Index: branches/iwtransclusion/phase3v2/includes/cache/HTMLCacheUpdate.php
@@ -223,12 +223,16 @@
224224 global $wgUseFileCache, $wgUseSquid, $wgLocalInterwiki;
225225
226226 $pagesByWiki = array();
 227+ $titleArray = array();
 228+ # Sort by WikiID in $pagesByWiki
 229+ # Create the distant titles for Squid in $titleArray
227230 foreach ( $distantPageArray as $row ) {
228231 $wikiid = $row->gtl_from_wiki;
229232 if( !isset( $pagesByWiki[$wikiid] ) ) {
230233 $pagesByWiki[$wikiid] = array();
231234 }
232235 $pagesByWiki[$wikiid][] = $row->gtl_from_page;
 236+ $titleArray[] = Title::makeTitle( $row->gtl_from_namespace, $row->gtl_from_title, '', $row->gil_interwiki );
233237 }
234238
235239 foreach ( $pagesByWiki as $wikiid => $pages ) {
@@ -243,6 +247,12 @@
244248 );
245249 }
246250 }
 251+
 252+ # Update squid
 253+ if ( $wgUseSquid ) {
 254+ $u = SquidUpdate::newFromTitles( $titleArray );
 255+ $u->doUpdate();
 256+ }
247257 }
248258 }
249259
Index: branches/iwtransclusion/phase3v2/includes/Title.php
@@ -3115,7 +3115,7 @@
31163116 if ( $wgEnableInterwikiTemplatesTracking && $wgGlobalDatabase ) {
31173117 $dbw2 = wfGetDB( DB_MASTER, array(), $wgGlobalDatabase );
31183118 $dbw2->update( 'globaltemplatelinks',
3119 - array( 'gtl_from_namespace' => $nt->getNsText(),
 3119+ array( 'gtl_from_namespace' => $nt->getNamespace(),
31203120 'gtl_from_title' => $nt->getText() ),
31213121 array ( 'gtl_from_page' => $pageid ),
31223122 __METHOD__ );
Property changes on: branches/iwtransclusion/phase3v2/includes/Title.php
___________________________________________________________________
Modified: svn:mergeinfo
31233123 Merged /branches/iwtransclusion/phase3/includes/Title.php:r76200
Index: branches/iwtransclusion/phase3v2/includes/GlobalUsageQuery.php
@@ -156,8 +156,12 @@
157157 }
158158
159159 /* Perform select (Duh.) */
160 - $res = $this->db->select( 'globaltemplatelinks',
 160+ $res = $this->db->select(
161161 array(
 162+ 'globaltemplatelinks',
 163+ 'globalnamespaces'
 164+ ),
 165+ array(
162166 'gtl_to_title',
163167 'gtl_from_wiki',
164168 'gtl_from_page',
@@ -170,6 +174,9 @@
171175 'ORDER BY' => "gtl_to_title $order, gtl_from_wiki $order, gtl_from_page $order",
172176 // Select an extra row to check whether we have more rows available
173177 'LIMIT' => $this->limit + 1,
 178+ ),
 179+ array(
 180+ 'gtl_from_namespace = gn_namespace'
174181 )
175182 );
176183
@@ -207,7 +214,7 @@
208215 $this->result[$row->gtl_to_title][$row->gtl_from_wiki][] = array(
209216 'template' => $row->gtl_to_title,
210217 'id' => $row->gtl_from_page,
211 - 'namespace' => $row->gtl_from_namespace,
 218+ 'namespace' => $row->gn_namespacetext,
212219 'title' => $row->gtl_from_title,
213220 'wiki' => $row->gtl_from_wiki,
214221 );
Index: branches/iwtransclusion/phase3v2/includes/specials/SpecialGlobalFileUsage.php
@@ -6,7 +6,7 @@
77
88 class SpecialGlobalFileUsage extends SpecialPage {
99 public function __construct() {
10 - parent::__construct( 'GlobalFileUsage', 'globalfileusage' );
 10+ parent::__construct( 'GlobalFileUsage' );
1111 }
1212
1313 /**
Property changes on: branches/iwtransclusion/phase3v2
___________________________________________________________________
Modified: svn:mergeinfo
1414 Merged /branches/iwtransclusion/phase3:r76200

Follow-up revisions

RevisionCommit summaryAuthorDate
r93000Merge r87115, merge of r76200reedy18:42, 24 July 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r76200Adding and using globalinterwiki and globalnamespaces tables; that should do ...peter1717:35, 6 November 2010

Status & tagging log