http://www.mediawiki.org/wiki/Special:Code/MediaWiki/76200
Revision: 76200
Author: peter17
Date: 2010-11-06 17:35:15 +0000 (Sat, 06 Nov 2010)
Log Message:
-----------
Adding and using globalinterwiki and globalnamespaces tables; that should do it
for Squid update
Modified Paths:
--------------
branches/iwtransclusion/phase3/includes/BacklinkCache.php
branches/iwtransclusion/phase3/includes/GlobalUsageQuery.php
branches/iwtransclusion/phase3/includes/HTMLCacheUpdate.php
branches/iwtransclusion/phase3/includes/LinksUpdate.php
branches/iwtransclusion/phase3/includes/Title.php
branches/iwtransclusion/phase3/includes/specials/SpecialGlobalFileUsage.php
branches/iwtransclusion/phase3/maintenance/archives/patch-globaltemplatelinks.sql
Added Paths:
-----------
branches/iwtransclusion/phase3/maintenance/archives/patch-globalinterwiki.sql
branches/iwtransclusion/phase3/maintenance/archives/patch-globalnamespaces.sql
Property Changed:
----------------
branches/iwtransclusion/phase3/
Property changes on: branches/iwtransclusion/phase3
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/REL1_15/phase3:51646
/branches/new-installer/phase3:43664-66004
/branches/sqlite:58211-58321
/trunk/phase3:67506-73220,73222-74205
+ /branches/REL1_15/phase3:51646
/branches/new-installer/phase3:43664-66004
/branches/sqlite:58211-58321
/trunk/phase3:67506-73220,73222-74205,74211-74805
Modified: branches/iwtransclusion/phase3/includes/BacklinkCache.php
===================================================================
--- branches/iwtransclusion/phase3/includes/BacklinkCache.php 2010-11-06
16:57:21 UTC (rev 76199)
+++ branches/iwtransclusion/phase3/includes/BacklinkCache.php 2010-11-06
17:35:15 UTC (rev 76200)
@@ -116,10 +116,12 @@
$dbr = $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase );
$res = $dbr->select(
- array( 'globaltemplatelinks' ),
- array( 'gtl_from_wiki', 'gtl_from_page' ),
+ array( 'globaltemplatelinks', 'globalinterwiki' ),
+ array( 'gtl_from_wiki', 'gtl_from_page',
'gtl_from_title', 'giw_prefix' ),
array( 'gtl_to_prefix' => $wgLocalInterwiki,
'gtl_to_title' => $this->title->getDBkey( ) ),
- __METHOD__
+ __METHOD__,
+ null,
+ array( 'gtl_from_wiki = giw_wikiid' )
);
return $res;
}
Modified: branches/iwtransclusion/phase3/includes/GlobalUsageQuery.php
===================================================================
--- branches/iwtransclusion/phase3/includes/GlobalUsageQuery.php
2010-11-06 16:57:21 UTC (rev 76199)
+++ branches/iwtransclusion/phase3/includes/GlobalUsageQuery.php
2010-11-06 17:35:15 UTC (rev 76200)
@@ -156,8 +156,12 @@
}
/* Perform select (Duh.) */
- $res = $this->db->select( 'globaltemplatelinks',
+ $res = $this->db->select(
array(
+ 'globaltemplatelinks',
+ 'globalnamespaces'
+ ),
+ array(
'gtl_to_title',
'gtl_from_wiki',
'gtl_from_page',
@@ -170,6 +174,9 @@
'ORDER BY' => "gtl_to_title $order,
gtl_from_wiki $order, gtl_from_page $order",
// Select an extra row to check whether
we have more rows available
'LIMIT' => $this->limit + 1,
+ ),
+ array(
+ 'gtl_from_namespace = gn_namespace'
)
);
@@ -207,7 +214,7 @@
$this->result[$row->gtl_to_title][$row->gtl_from_wiki][] = array(
'template' => $row->gtl_to_title,
'id' => $row->gtl_from_page,
- 'namespace' => $row->gtl_from_namespace,
+ 'namespace' => $row->gn_namespacetext,
'title' => $row->gtl_from_title,
'wiki' => $row->gtl_from_wiki,
);
Modified: branches/iwtransclusion/phase3/includes/HTMLCacheUpdate.php
===================================================================
--- branches/iwtransclusion/phase3/includes/HTMLCacheUpdate.php 2010-11-06
16:57:21 UTC (rev 76199)
+++ branches/iwtransclusion/phase3/includes/HTMLCacheUpdate.php 2010-11-06
17:35:15 UTC (rev 76200)
@@ -219,12 +219,18 @@
global $wgUseFileCache, $wgUseSquid, $wgLocalInterwiki;
$pagesByWiki = array();
+ $titleArray = array();
+
+ # Sort by WikiID in $pagesByWiki
+ # Create the distant titles for Squid in $titleArray
foreach ( $distantPageArray as $row ) {
$wikiid = $row->gtl_from_wiki;
if( !isset( $pagesByWiki[$wikiid] ) ) {
$pagesByWiki[$wikiid] = array();
}
$pagesByWiki[$wikiid][] = $row->gtl_from_page;
+
+ $titleArray[] = Title::makeTitle(
$row->gtl_from_namespace, $row->gtl_from_title, '', $row->gil_interwiki );
}
foreach ( $pagesByWiki as $wikiid => $pages ) {
@@ -239,6 +245,12 @@
);
}
}
+
+ # Update squid
+ if ( $wgUseSquid ) {
+ $u = SquidUpdate::newFromTitles( $titleArray );
+ $u->doUpdate();
+ }
}
}
Modified: branches/iwtransclusion/phase3/includes/LinksUpdate.php
===================================================================
--- branches/iwtransclusion/phase3/includes/LinksUpdate.php 2010-11-06
16:57:21 UTC (rev 76199)
+++ branches/iwtransclusion/phase3/includes/LinksUpdate.php 2010-11-06
17:35:15 UTC (rev 76200)
@@ -379,7 +379,9 @@
$dbw->delete( $table, $where, __METHOD__ );
}
if ( count( $insertions ) ) {
- $dbw->insert( $table, $insertions, __METHOD__,
'IGNORE' );
+ $dbw->insert( 'globaltemplatelinks',
$insertions['globaltemplatelinks'], __METHOD__, 'IGNORE' );
+ $dbw->insert( 'globalnamespaces',
$insertions['globalnamespaces'], __METHOD__, 'IGNORE' );
+ $dbw->insert( 'globalinterwiki',
$insertions['globalinterwiki'], __METHOD__, 'IGNORE' );
}
}
}
@@ -433,16 +435,27 @@
foreach( $this->mDistantTemplates as $prefix => $templatesToNS
) {
foreach( $templatesToNS as $ns => $dbkeys ) {
$diffs = isset( $existing[$prefix] ) && isset(
$existing[$prefix][$ns] ) ? array_diff_key( $dbkeys, $existing[$prefix][$ns] )
: $dbkeys;
+ $interwiki = Interwiki::fetch( $prefix );
+ $wikiid = $interwiki->getWikiID( );
foreach ( $diffs as $dbk => $id ) {
- $arr[] = array(
+ $arr['globaltemplatelinks'][] = array(
'gtl_from_wiki' =>
wfWikiID( ),
'gtl_from_page' =>
$this->mId,
- 'gtl_from_namespace' =>
$this->mTitle->getNsText(),
+ 'gtl_from_namespace' =>
$this->mTitle->getNamespace(),
'gtl_from_title' =>
$this->mTitle->getText(),
'gtl_to_prefix' => $prefix,
'gtl_to_namespace' => $ns,
'gtl_to_title' => $dbk
);
+ $arr['globalinterwiki'][] = array(
+ 'giw_wikiid' =>
$wikiid,
+ 'giw_prefix' =>
$prefix
+ );
+ $arr['globalnamespaces'][] = array(
+ 'gn_wiki'
=> wfWikiID( ),
+ 'gn_namespace' =>
$this->mTitle->getNamespace(),
+ 'gn_namespacetext' =>
$this->mTitle->getNsText(),
+ );
}
}
}
Modified: branches/iwtransclusion/phase3/includes/Title.php
===================================================================
--- branches/iwtransclusion/phase3/includes/Title.php 2010-11-06 16:57:21 UTC
(rev 76199)
+++ branches/iwtransclusion/phase3/includes/Title.php 2010-11-06 17:35:15 UTC
(rev 76200)
@@ -3123,7 +3123,7 @@
if ( $wgEnableInterwikiTemplatesTracking && $wgGlobalDatabase )
{
$dbw2 = wfGetDB( DB_MASTER, array(), $wgGlobalDatabase
);
$dbw2->update( 'globaltemplatelinks',
- array( 'gtl_from_namespace' =>
$nt->getNsText(),
+ array( 'gtl_from_namespace' =>
$nt->getNamespace(),
'gtl_from_title' => $nt->getText() ),
array ( 'gtl_from_page' =>
$pageid ),
__METHOD__ );
Modified:
branches/iwtransclusion/phase3/includes/specials/SpecialGlobalFileUsage.php
===================================================================
--- branches/iwtransclusion/phase3/includes/specials/SpecialGlobalFileUsage.php
2010-11-06 16:57:21 UTC (rev 76199)
+++ branches/iwtransclusion/phase3/includes/specials/SpecialGlobalFileUsage.php
2010-11-06 17:35:15 UTC (rev 76200)
@@ -6,7 +6,7 @@
class SpecialGlobalFileUsage extends SpecialPage {
public function __construct() {
- parent::__construct( 'GlobalFileUsage', 'globalfileusage' );
+ parent::__construct( 'GlobalFileUsage' );
}
/**
Added:
branches/iwtransclusion/phase3/maintenance/archives/patch-globalinterwiki.sql
===================================================================
---
branches/iwtransclusion/phase3/maintenance/archives/patch-globalinterwiki.sql
(rev 0)
+++
branches/iwtransclusion/phase3/maintenance/archives/patch-globalinterwiki.sql
2010-11-06 17:35:15 UTC (rev 76200)
@@ -0,0 +1,10 @@
+-- Table associating distant wiki IDs with their interwiki prefixes.
+CREATE TABLE /*_*/globalinterwiki (
+ -- The wiki ID of the wiki
+ giw_wikiid varchar(64) NOT NULL,
+
+ -- The interwiki prefix of that wiki
+ giw_prefix varchar(32) NOT NULL
+
+) /*$wgDBTableOptions*/;
+CREATE UNIQUE INDEX /*i*/giw_index ON /*_*/globalinterwiki (giw_wikiid,
giw_prefix);
Added:
branches/iwtransclusion/phase3/maintenance/archives/patch-globalnamespaces.sql
===================================================================
---
branches/iwtransclusion/phase3/maintenance/archives/patch-globalnamespaces.sql
(rev 0)
+++
branches/iwtransclusion/phase3/maintenance/archives/patch-globalnamespaces.sql
2010-11-06 17:35:15 UTC (rev 76200)
@@ -0,0 +1,14 @@
+-- Table listing distant wiki namespace texts.
+CREATE TABLE /*_*/globalnamespaces (
+ -- The wiki ID of the remote wiki
+ gn_wiki varchar(64) NOT NULL,
+
+ -- The namespace ID of the transcluded page on that wiki
+ gn_namespace int NOT NULL,
+
+ -- The namespace text of transcluded page
+ -- Needed for display purposes, since the local namespace ID doesn't
necessarily match a distant one
+ gn_namespacetext varchar(255) NOT NULL
+
+) /*$wgDBTableOptions*/;
+CREATE UNIQUE INDEX /*i*/gn_index ON /*_*/globalnamespaces (gn_wiki,
gn_namespace, gn_namespacetext);
Modified:
branches/iwtransclusion/phase3/maintenance/archives/patch-globaltemplatelinks.sql
===================================================================
---
branches/iwtransclusion/phase3/maintenance/archives/patch-globaltemplatelinks.sql
2010-11-06 16:57:21 UTC (rev 76199)
+++
branches/iwtransclusion/phase3/maintenance/archives/patch-globaltemplatelinks.sql
2010-11-06 17:35:15 UTC (rev 76200)
@@ -9,9 +9,10 @@
-- The page ID of the calling page on the remote wiki
gtl_from_page int unsigned NOT NULL,
- -- The namespace name of the calling page on the remote wiki
+ -- The namespace of the calling page on the remote wiki
-- Needed for display purposes, since the foreign namespace ID doesn't
necessarily match a local one
- gtl_from_namespace varchar(255) NOT NULL,
+ -- The link between the namespace and the namespace name is made by the
globalnamespaces table
+ gtl_from_namespace int NOT NULL,
-- The title of the calling page on the remote wiki
-- Needed for display purposes
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs