Index: branches/iwtransclusion/phase3v2/maintenance/archives/patch-globaltemplatelinks.sql |
— | — | @@ -9,9 +9,10 @@ |
10 | 10 | -- The page ID of the calling page on the remote wiki |
11 | 11 | gtl_from_page int unsigned NOT NULL, |
12 | 12 | |
13 | | - -- The namespace name of the calling page on the remote wiki |
| 13 | + -- The namespace of the calling page on the remote wiki |
14 | 14 | -- 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, |
16 | 17 | |
17 | 18 | -- The title of the calling page on the remote wiki |
18 | 19 | -- 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 @@ |
353 | 353 | $this->mDb->insert( $table, $insertions, __METHOD__, 'IGNORE' ); |
354 | 354 | } |
355 | 355 | } |
| 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 | + } |
356 | 389 | |
357 | 390 | |
358 | 391 | /** |
— | — | @@ -393,6 +426,37 @@ |
394 | 427 | return $arr; |
395 | 428 | } |
396 | 429 | |
| 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 | + |
397 | 461 | /** |
398 | 462 | * Get an array of image insertions |
399 | 463 | * Skips the names specified in $existing |
Index: branches/iwtransclusion/phase3v2/includes/BacklinkCache.php |
— | — | @@ -181,10 +181,12 @@ |
182 | 182 | |
183 | 183 | $dbr = $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase ); |
184 | 184 | $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' ), |
187 | 187 | array( 'gtl_to_prefix' => $wgLocalInterwiki, 'gtl_to_title' => $this->title->getDBkey( ) ), |
188 | | - __METHOD__ |
| 188 | + __METHOD__, |
| 189 | + null, |
| 190 | + array( 'gtl_from_wiki = giw_wikiid' ) |
189 | 191 | ); |
190 | 192 | return $res; |
191 | 193 | } |
Index: branches/iwtransclusion/phase3v2/includes/cache/HTMLCacheUpdate.php |
— | — | @@ -223,12 +223,16 @@ |
224 | 224 | global $wgUseFileCache, $wgUseSquid, $wgLocalInterwiki; |
225 | 225 | |
226 | 226 | $pagesByWiki = array(); |
| 227 | + $titleArray = array(); |
| 228 | + # Sort by WikiID in $pagesByWiki |
| 229 | + # Create the distant titles for Squid in $titleArray |
227 | 230 | foreach ( $distantPageArray as $row ) { |
228 | 231 | $wikiid = $row->gtl_from_wiki; |
229 | 232 | if( !isset( $pagesByWiki[$wikiid] ) ) { |
230 | 233 | $pagesByWiki[$wikiid] = array(); |
231 | 234 | } |
232 | 235 | $pagesByWiki[$wikiid][] = $row->gtl_from_page; |
| 236 | + $titleArray[] = Title::makeTitle( $row->gtl_from_namespace, $row->gtl_from_title, '', $row->gil_interwiki ); |
233 | 237 | } |
234 | 238 | |
235 | 239 | foreach ( $pagesByWiki as $wikiid => $pages ) { |
— | — | @@ -243,6 +247,12 @@ |
244 | 248 | ); |
245 | 249 | } |
246 | 250 | } |
| 251 | + |
| 252 | + # Update squid |
| 253 | + if ( $wgUseSquid ) { |
| 254 | + $u = SquidUpdate::newFromTitles( $titleArray ); |
| 255 | + $u->doUpdate(); |
| 256 | + } |
247 | 257 | } |
248 | 258 | } |
249 | 259 | |
Index: branches/iwtransclusion/phase3v2/includes/Title.php |
— | — | @@ -3115,7 +3115,7 @@ |
3116 | 3116 | if ( $wgEnableInterwikiTemplatesTracking && $wgGlobalDatabase ) { |
3117 | 3117 | $dbw2 = wfGetDB( DB_MASTER, array(), $wgGlobalDatabase ); |
3118 | 3118 | $dbw2->update( 'globaltemplatelinks', |
3119 | | - array( 'gtl_from_namespace' => $nt->getNsText(), |
| 3119 | + array( 'gtl_from_namespace' => $nt->getNamespace(), |
3120 | 3120 | 'gtl_from_title' => $nt->getText() ), |
3121 | 3121 | array ( 'gtl_from_page' => $pageid ), |
3122 | 3122 | __METHOD__ ); |
Property changes on: branches/iwtransclusion/phase3v2/includes/Title.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
3123 | 3123 | Merged /branches/iwtransclusion/phase3/includes/Title.php:r76200 |
Index: branches/iwtransclusion/phase3v2/includes/GlobalUsageQuery.php |
— | — | @@ -156,8 +156,12 @@ |
157 | 157 | } |
158 | 158 | |
159 | 159 | /* Perform select (Duh.) */ |
160 | | - $res = $this->db->select( 'globaltemplatelinks', |
| 160 | + $res = $this->db->select( |
161 | 161 | array( |
| 162 | + 'globaltemplatelinks', |
| 163 | + 'globalnamespaces' |
| 164 | + ), |
| 165 | + array( |
162 | 166 | 'gtl_to_title', |
163 | 167 | 'gtl_from_wiki', |
164 | 168 | 'gtl_from_page', |
— | — | @@ -170,6 +174,9 @@ |
171 | 175 | 'ORDER BY' => "gtl_to_title $order, gtl_from_wiki $order, gtl_from_page $order", |
172 | 176 | // Select an extra row to check whether we have more rows available |
173 | 177 | 'LIMIT' => $this->limit + 1, |
| 178 | + ), |
| 179 | + array( |
| 180 | + 'gtl_from_namespace = gn_namespace' |
174 | 181 | ) |
175 | 182 | ); |
176 | 183 | |
— | — | @@ -207,7 +214,7 @@ |
208 | 215 | $this->result[$row->gtl_to_title][$row->gtl_from_wiki][] = array( |
209 | 216 | 'template' => $row->gtl_to_title, |
210 | 217 | 'id' => $row->gtl_from_page, |
211 | | - 'namespace' => $row->gtl_from_namespace, |
| 218 | + 'namespace' => $row->gn_namespacetext, |
212 | 219 | 'title' => $row->gtl_from_title, |
213 | 220 | 'wiki' => $row->gtl_from_wiki, |
214 | 221 | ); |
Index: branches/iwtransclusion/phase3v2/includes/specials/SpecialGlobalFileUsage.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | |
8 | 8 | class SpecialGlobalFileUsage extends SpecialPage { |
9 | 9 | public function __construct() { |
10 | | - parent::__construct( 'GlobalFileUsage', 'globalfileusage' ); |
| 10 | + parent::__construct( 'GlobalFileUsage' ); |
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
Property changes on: branches/iwtransclusion/phase3v2 |
___________________________________________________________________ |
Modified: svn:mergeinfo |
14 | 14 | Merged /branches/iwtransclusion/phase3:r76200 |