r76200 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76199‎ | r76200 | r76201 >
Date:17:35, 6 November 2010
Author:peter17
Status:ok
Tags:
Comment:
Adding and using globalinterwiki and globalnamespaces tables; that should do it for Squid update
Modified paths:
  • /branches/iwtransclusion/phase3 (modified) (history)
  • /branches/iwtransclusion/phase3/includes/BacklinkCache.php (modified) (history)
  • /branches/iwtransclusion/phase3/includes/GlobalUsageQuery.php (modified) (history)
  • /branches/iwtransclusion/phase3/includes/HTMLCacheUpdate.php (modified) (history)
  • /branches/iwtransclusion/phase3/includes/LinksUpdate.php (modified) (history)
  • /branches/iwtransclusion/phase3/includes/Title.php (modified) (history)
  • /branches/iwtransclusion/phase3/includes/specials/SpecialGlobalFileUsage.php (modified) (history)
  • /branches/iwtransclusion/phase3/maintenance/archives/patch-globalinterwiki.sql (added) (history)
  • /branches/iwtransclusion/phase3/maintenance/archives/patch-globalnamespaces.sql (added) (history)
  • /branches/iwtransclusion/phase3/maintenance/archives/patch-globaltemplatelinks.sql (modified) (history)

Diff [purge]

Index: branches/iwtransclusion/phase3/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/phase3/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/phase3/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/phase3/includes/LinksUpdate.php
@@ -379,7 +379,9 @@
380380 $dbw->delete( $table, $where, __METHOD__ );
381381 }
382382 if ( count( $insertions ) ) {
383 - $dbw->insert( $table, $insertions, __METHOD__, 'IGNORE' );
 383+ $dbw->insert( 'globaltemplatelinks', $insertions['globaltemplatelinks'], __METHOD__, 'IGNORE' );
 384+ $dbw->insert( 'globalnamespaces', $insertions['globalnamespaces'], __METHOD__, 'IGNORE' );
 385+ $dbw->insert( 'globalinterwiki', $insertions['globalinterwiki'], __METHOD__, 'IGNORE' );
384386 }
385387 }
386388 }
@@ -433,16 +435,27 @@
434436 foreach( $this->mDistantTemplates as $prefix => $templatesToNS ) {
435437 foreach( $templatesToNS as $ns => $dbkeys ) {
436438 $diffs = isset( $existing[$prefix] ) && isset( $existing[$prefix][$ns] ) ? array_diff_key( $dbkeys, $existing[$prefix][$ns] ) : $dbkeys;
 439+ $interwiki = Interwiki::fetch( $prefix );
 440+ $wikiid = $interwiki->getWikiID( );
437441 foreach ( $diffs as $dbk => $id ) {
438 - $arr[] = array(
 442+ $arr['globaltemplatelinks'][] = array(
439443 'gtl_from_wiki' => wfWikiID( ),
440444 'gtl_from_page' => $this->mId,
441 - 'gtl_from_namespace' => $this->mTitle->getNsText(),
 445+ 'gtl_from_namespace' => $this->mTitle->getNamespace(),
442446 'gtl_from_title' => $this->mTitle->getText(),
443447 'gtl_to_prefix' => $prefix,
444448 'gtl_to_namespace' => $ns,
445449 'gtl_to_title' => $dbk
446450 );
 451+ $arr['globalinterwiki'][] = array(
 452+ 'giw_wikiid' => $wikiid,
 453+ 'giw_prefix' => $prefix
 454+ );
 455+ $arr['globalnamespaces'][] = array(
 456+ 'gn_wiki' => wfWikiID( ),
 457+ 'gn_namespace' => $this->mTitle->getNamespace(),
 458+ 'gn_namespacetext' => $this->mTitle->getNsText(),
 459+ );
447460 }
448461 }
449462 }
Index: branches/iwtransclusion/phase3/includes/BacklinkCache.php
@@ -116,10 +116,12 @@
117117
118118 $dbr = $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase );
119119 $res = $dbr->select(
120 - array( 'globaltemplatelinks' ),
121 - array( 'gtl_from_wiki', 'gtl_from_page' ),
 120+ array( 'globaltemplatelinks', 'globalinterwiki' ),
 121+ array( 'gtl_from_wiki', 'gtl_from_page', 'gtl_from_title', 'giw_prefix' ),
122122 array( 'gtl_to_prefix' => $wgLocalInterwiki, 'gtl_to_title' => $this->title->getDBkey( ) ),
123 - __METHOD__
 123+ __METHOD__,
 124+ null,
 125+ array( 'gtl_from_wiki = giw_wikiid' )
124126 );
125127 return $res;
126128 }
Index: branches/iwtransclusion/phase3/includes/Title.php
@@ -3123,7 +3123,7 @@
31243124 if ( $wgEnableInterwikiTemplatesTracking && $wgGlobalDatabase ) {
31253125 $dbw2 = wfGetDB( DB_MASTER, array(), $wgGlobalDatabase );
31263126 $dbw2->update( 'globaltemplatelinks',
3127 - array( 'gtl_from_namespace' => $nt->getNsText(),
 3127+ array( 'gtl_from_namespace' => $nt->getNamespace(),
31283128 'gtl_from_title' => $nt->getText() ),
31293129 array ( 'gtl_from_page' => $pageid ),
31303130 __METHOD__ );
Index: branches/iwtransclusion/phase3/includes/HTMLCacheUpdate.php
@@ -219,12 +219,18 @@
220220 global $wgUseFileCache, $wgUseSquid, $wgLocalInterwiki;
221221
222222 $pagesByWiki = array();
 223+ $titleArray = array();
 224+
 225+ # Sort by WikiID in $pagesByWiki
 226+ # Create the distant titles for Squid in $titleArray
223227 foreach ( $distantPageArray as $row ) {
224228 $wikiid = $row->gtl_from_wiki;
225229 if( !isset( $pagesByWiki[$wikiid] ) ) {
226230 $pagesByWiki[$wikiid] = array();
227231 }
228232 $pagesByWiki[$wikiid][] = $row->gtl_from_page;
 233+
 234+ $titleArray[] = Title::makeTitle( $row->gtl_from_namespace, $row->gtl_from_title, '', $row->gil_interwiki );
229235 }
230236
231237 foreach ( $pagesByWiki as $wikiid => $pages ) {
@@ -239,6 +245,12 @@
240246 );
241247 }
242248 }
 249+
 250+ # Update squid
 251+ if ( $wgUseSquid ) {
 252+ $u = SquidUpdate::newFromTitles( $titleArray );
 253+ $u->doUpdate();
 254+ }
243255 }
244256 }
245257
Index: branches/iwtransclusion/phase3/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/phase3/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/phase3
___________________________________________________________________
Modified: svn:mergeinfo
1414 Merged /trunk/phase3:r74211-74805

Follow-up revisions

RevisionCommit summaryAuthorDate
r87115Merge r76200...reedy01:04, 29 April 2011
r93000Merge r87115, merge of r76200reedy18:42, 24 July 2011
r113031Create a branch from r76200 of iwtransclusion/phase3 to drop all the merges I...reedy13:30, 5 March 2012

Status & tagging log