Index: branches/iwtransclusion/phase3/maintenance/archives/patch-globaltemplatelinks.sql |
— | — | @@ -17,15 +17,19 @@ |
18 | 18 | -- Needed for display purposes |
19 | 19 | gtl_from_title varchar(255) binary NOT NULL, |
20 | 20 | |
21 | | - -- The wiki ID of the wiki that hosts the transcluded page |
22 | | - gtl_to_wiki varchar(64) NOT NULL, |
| 21 | + -- The interwiki prefix of the wiki that hosts the transcluded page |
| 22 | + gtl_to_prefix varchar(32) NOT NULL, |
23 | 23 | |
24 | 24 | -- The namespace of the transcluded page on that wiki |
25 | 25 | gtl_to_namespace int NOT NULL, |
26 | 26 | |
| 27 | + -- The namespace name of transcluded page |
| 28 | + -- Needed for display purposes, since the local namespace ID doesn't necessarily match a distant one |
| 29 | + gtl_to_namespacetext varchar(255) NOT NULL, |
| 30 | + |
27 | 31 | -- The title of the transcluded page on that wiki |
28 | 32 | gtl_to_title varchar(255) binary NOT NULL |
29 | 33 | ) /*$wgDBTableOptions*/; |
30 | 34 | |
31 | | -CREATE UNIQUE INDEX /*i*/gtl_to_from ON /*_*/globaltemplatelinks (gtl_to_wiki, gtl_to_namespace, gtl_to_title, gtl_from_wiki, gtl_from_page); |
32 | | -CREATE UNIQUE INDEX /*i*/gtl_from_to ON /*_*/globaltemplatelinks (gtl_from_wiki, gtl_from_page, gtl_to_wiki, gtl_to_namespace, gtl_to_title); |
| 35 | +CREATE UNIQUE INDEX /*i*/gtl_to_from ON /*_*/globaltemplatelinks (gtl_to_prefix, gtl_to_namespace, gtl_to_title, gtl_from_wiki, gtl_from_page); |
| 36 | +CREATE UNIQUE INDEX /*i*/gtl_from_to ON /*_*/globaltemplatelinks (gtl_from_wiki, gtl_from_page, gtl_to_prefix, gtl_to_namespace, gtl_to_title); |
Index: branches/iwtransclusion/phase3/maintenance/language/messages.inc |
— | — | @@ -586,6 +586,9 @@ |
587 | 587 | 'templatesused', |
588 | 588 | 'templatesusedpreview', |
589 | 589 | 'templatesusedsection', |
| 590 | + 'distanttemplatesused', |
| 591 | + 'distanttemplatesusedpreview', |
| 592 | + 'distanttemplatesusedsection', |
590 | 593 | 'template-protected', |
591 | 594 | 'template-semiprotected', |
592 | 595 | 'hiddencategories', |
Index: branches/iwtransclusion/phase3/includes/Article.php |
— | — | @@ -3172,7 +3172,7 @@ |
3173 | 3173 | * @return boolean true if successful |
3174 | 3174 | */ |
3175 | 3175 | public function doDeleteArticle( $reason, $suppress = false, $id = 0, $commit = true ) { |
3176 | | - global $wgDeferredUpdateList, $wgUseTrackbacks, $wgGlobalDB, $wgWikiID; |
| 3176 | + global $wgDeferredUpdateList, $wgUseTrackbacks, $wgEnableInterwikiTemplatesTracking, $wgGlobalDatabase; |
3177 | 3177 | |
3178 | 3178 | wfDebug( __METHOD__ . "\n" ); |
3179 | 3179 | |
— | — | @@ -3271,11 +3271,11 @@ |
3272 | 3272 | $dbw->delete( 'langlinks', array( 'll_from' => $id ) ); |
3273 | 3273 | $dbw->delete( 'redirect', array( 'rd_from' => $id ) ); |
3274 | 3274 | |
3275 | | - if ( $wgGlobalDB ) { |
3276 | | - $dbw2 = wfGetDB( DB_MASTER, array(), $wgGlobalDB ); |
| 3275 | + if ( $wgEnableInterwikiTemplatesTracking && $wgGlobalDatabase ) { |
| 3276 | + $dbw2 = wfGetDB( DB_MASTER, array(), $wgGlobalDatabase ); |
3277 | 3277 | $dbw2->delete( 'globaltemplatelinks', |
3278 | | - array( 'gtl_from_wiki' => $wgWikiID, |
3279 | | - 'gtl_from_page' => $id ) |
| 3278 | + array( 'gtl_from_wiki' => wfWikiID( ), |
| 3279 | + 'gtl_from_page' => $id ) |
3280 | 3280 | ); |
3281 | 3281 | } |
3282 | 3282 | } |
— | — | @@ -4312,6 +4312,42 @@ |
4313 | 4313 | } |
4314 | 4314 | |
4315 | 4315 | /** |
| 4316 | + * Return a list of distant templates used by this article. |
| 4317 | + * Uses the globaltemplatelinks table |
| 4318 | + * |
| 4319 | + * @return Array of Title objects |
| 4320 | + */ |
| 4321 | + public function getUsedDistantTemplates() { |
| 4322 | + global $wgGlobalDatabase; |
| 4323 | + |
| 4324 | + $result = array(); |
| 4325 | + |
| 4326 | + if ( $wgGlobalDatabase ) { |
| 4327 | + $id = $this->mTitle->getArticleID(); |
| 4328 | + |
| 4329 | + if ( $id == 0 ) { |
| 4330 | + return array(); |
| 4331 | + } |
| 4332 | + |
| 4333 | + $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase ); |
| 4334 | + $res = $dbr->select( array( 'globaltemplatelinks' ), |
| 4335 | + array( 'gtl_to_prefix', 'gtl_to_namespace', 'gtl_to_title' ), |
| 4336 | + array( 'gtl_from_wiki' => wfWikiID( ), 'gtl_from_page' => $id ), |
| 4337 | + __METHOD__ ); |
| 4338 | + |
| 4339 | + if ( $res !== false ) { |
| 4340 | + foreach ( $res as $row ) { |
| 4341 | + $result[] = Title::makeTitle( $row->gtl_to_namespace, $row->gtl_to_title, null, $row->gtl_to_prefix ); |
| 4342 | + } |
| 4343 | + } |
| 4344 | + |
| 4345 | + $dbr->freeResult( $res ); |
| 4346 | + } |
| 4347 | + |
| 4348 | + return $result; |
| 4349 | + } |
| 4350 | + |
| 4351 | + /** |
4316 | 4352 | * Returns a list of hidden categories this page is a member of. |
4317 | 4353 | * Uses the page_props and categorylinks tables. |
4318 | 4354 | * |
Index: branches/iwtransclusion/phase3/includes/parser/Parser.php |
— | — | @@ -2959,7 +2959,7 @@ |
2960 | 2960 | * @private |
2961 | 2961 | */ |
2962 | 2962 | function braceSubstitution( $piece, $frame ) { |
2963 | | - global $wgContLang, $wgNonincludableNamespaces; |
| 2963 | + global $wgContLang, $wgNonincludableNamespaces, $wgEnableInterwikiTranscluding, $wgEnableInterwikiTemplatesTracking; |
2964 | 2964 | wfProfileIn( __METHOD__ ); |
2965 | 2965 | wfProfileIn( __METHOD__.'-setup' ); |
2966 | 2966 | |
— | — | @@ -3172,12 +3172,15 @@ |
3173 | 3173 | $text = "[[:$titleText]]"; |
3174 | 3174 | $found = true; |
3175 | 3175 | } |
3176 | | - } elseif ( $title->isTrans() ) { |
| 3176 | + } elseif ( $wgEnableInterwikiTranscluding && $title->isTrans() ) { |
3177 | 3177 | // TODO: Work by Peter17 in progress |
3178 | 3178 | |
3179 | 3179 | $text = Interwiki::interwikiTransclude( $title ); |
3180 | | - $this->registerDistantTemplate( $title ); |
3181 | 3180 | |
| 3181 | + if ( $wgEnableInterwikiTemplatesTracking ) { |
| 3182 | + $this->registerDistantTemplate( $title ); |
| 3183 | + } |
| 3184 | + |
3182 | 3185 | if ( $text !== false ) { |
3183 | 3186 | # Preprocess it like a template |
3184 | 3187 | $text = $this->preprocessToDom( $text, self::PTD_FOR_INCLUSION ); |
— | — | @@ -3329,8 +3332,7 @@ |
3330 | 3333 | * Register a distant template as used |
3331 | 3334 | */ |
3332 | 3335 | function registerDistantTemplate( $title ) { |
3333 | | - $templateCb = array( 'Parser', 'distantTemplateCallback' ); |
3334 | | - $stuff = call_user_func( $templateCb, $title, $this ); |
| 3336 | + $stuff = Parser::distantTemplateCallback( $title, $this ); |
3335 | 3337 | $text = $stuff['text']; |
3336 | 3338 | $finalTitle = isset( $stuff['finalTitle'] ) ? $stuff['finalTitle'] : $title; |
3337 | 3339 | if ( isset( $stuff['deps'] ) ) { |
Index: branches/iwtransclusion/phase3/includes/parser/ParserOutput.php |
— | — | @@ -209,21 +209,27 @@ |
210 | 210 | } |
211 | 211 | |
212 | 212 | function addDistantTemplate( $title, $page_id, $rev_id ) { |
213 | | - $wikiid = $title->getTransWikiID(); |
214 | | - if ( $wikiid !=='' ) { |
| 213 | + $prefix = $title->getInterwiki(); |
| 214 | + if ( $prefix !=='' ) { |
215 | 215 | $ns = $title->getNamespace(); |
216 | 216 | $dbk = $title->getDBkey(); |
217 | | - if ( !isset( $this->mDistantTemplates[$wikiid] ) ) { |
218 | | - $this->mDistantTemplates[$wikiid] = array(); |
| 217 | + |
| 218 | + if ( !isset( $this->mDistantTemplates[$prefix] ) ) { |
| 219 | + $this->mDistantTemplates[$prefix] = array(); |
219 | 220 | } |
220 | | - if ( !isset( $this->mDistantTemplates[$wikiid][$ns] ) ) { |
221 | | - $this->mDistantTemplates[$wikiid][$ns] = array(); |
| 221 | + if ( !isset( $this->mDistantTemplates[$prefix][$ns] ) ) { |
| 222 | + $this->mDistantTemplates[$prefix][$ns] = array(); |
222 | 223 | } |
223 | | - $this->mDistantTemplates[$wikiid][$ns][$dbk] = $page_id; |
224 | | - if ( !isset( $this->mDistantTemplateIds[$wikiid][$ns] ) ) { |
225 | | - $this->mDistantTemplateIds[$wikiid][$ns] = array(); |
| 224 | + $this->mDistantTemplates[$prefix][$ns][$dbk] = $page_id; |
| 225 | + |
| 226 | + // For versioning |
| 227 | + if ( !isset( $this->mDistantTemplateIds[$prefix] ) ) { |
| 228 | + $this->mDistantTemplateIds[$prefix] = array(); |
226 | 229 | } |
227 | | - $this->mDistantTemplateIds[$wikiid][$ns][$dbk] = $rev_id; // For versioning |
| 230 | + if ( !isset( $this->mDistantTemplateIds[$prefix][$ns] ) ) { |
| 231 | + $this->mDistantTemplateIds[$prefix][$ns] = array(); |
| 232 | + } |
| 233 | + $this->mDistantTemplateIds[$prefix][$ns][$dbk] = $rev_id; |
228 | 234 | } |
229 | 235 | } |
230 | 236 | |
Index: branches/iwtransclusion/phase3/includes/Linker.php |
— | — | @@ -1575,6 +1575,48 @@ |
1576 | 1576 | } |
1577 | 1577 | |
1578 | 1578 | /** |
| 1579 | + * Returns HTML for the "templates used on this page" list. |
| 1580 | + * |
| 1581 | + * @param $templates Array of templates from Article::getUsedTemplate |
| 1582 | + * or similar |
| 1583 | + * @param $preview Boolean: whether this is for a preview |
| 1584 | + * @param $section Boolean: whether this is for a section edit |
| 1585 | + * @return String: HTML output |
| 1586 | + */ |
| 1587 | + public function formatDistantTemplates( $templates, $preview = false, $section = false ) { |
| 1588 | + wfProfileIn( __METHOD__ ); |
| 1589 | + |
| 1590 | + $outText = ''; |
| 1591 | + if ( count( $templates ) > 0 ) { |
| 1592 | + # Do a batch existence check |
| 1593 | + $batch = new LinkBatch; |
| 1594 | + foreach( $templates as $title ) { |
| 1595 | + $batch->addObj( $title ); |
| 1596 | + } |
| 1597 | + $batch->execute(); |
| 1598 | + |
| 1599 | + # Construct the HTML |
| 1600 | + $outText = '<div class="mw-templatesUsedExplanation">'; |
| 1601 | + if ( $preview ) { |
| 1602 | + $outText .= wfMsgExt( 'distanttemplatesusedpreview', array( 'parse' ), count( $templates ) ); |
| 1603 | + } elseif ( $section ) { |
| 1604 | + $outText .= wfMsgExt( 'distanttemplatesusedsection', array( 'parse' ), count( $templates ) ); |
| 1605 | + } else { |
| 1606 | + $outText .= wfMsgExt( 'distanttemplatesused', array( 'parse' ), count( $templates ) ); |
| 1607 | + } |
| 1608 | + $outText .= "</div><ul>\n"; |
| 1609 | + |
| 1610 | + usort( $templates, array( 'Title', 'compare' ) ); |
| 1611 | + foreach ( $templates as $titleObj ) { |
| 1612 | + $outText .= '<li>' . $this->link( $titleObj ) . '</li>'; |
| 1613 | + } |
| 1614 | + $outText .= '</ul>'; |
| 1615 | + } |
| 1616 | + wfProfileOut( __METHOD__ ); |
| 1617 | + return $outText; |
| 1618 | + } |
| 1619 | + |
| 1620 | + /** |
1579 | 1621 | * Returns HTML for the "hidden categories on this page" list. |
1580 | 1622 | * |
1581 | 1623 | * @param $hiddencats Array of hidden categories from Article::getHiddenCategories |
Index: branches/iwtransclusion/phase3/includes/db/Database.php |
— | — | @@ -1287,7 +1287,7 @@ |
1288 | 1288 | * The keys on each level may be either integers or strings. |
1289 | 1289 | * |
1290 | 1290 | * @param $data Array: organized as 3-d array(baseKeyVal => array(middleKeyVal => array(subKeyVal => <ignored>, ...), ...), ...) |
1291 | | - * @param $baseKey String: field name to match the base-level keys to (eg 'gtl_to_wikiid') |
| 1291 | + * @param $baseKey String: field name to match the base-level keys to (eg 'gtl_to_prefix') |
1292 | 1292 | * @param $middleKey String: field name to match the middle-level keys to (eg 'gtl_to_namespace') |
1293 | 1293 | * @param $subKey String: field name to match the sub-level keys to (eg 'gtl_to_title') |
1294 | 1294 | * @return Mixed: string SQL fragment, or false if no items in array. |
— | — | @@ -1297,9 +1297,12 @@ |
1298 | 1298 | foreach ( $data as $base => $subdata ) { |
1299 | 1299 | foreach ( $subdata as $middle => $sub ) { |
1300 | 1300 | if ( count( $sub ) ) { |
1301 | | - $conds[] = $this->makeList( |
1302 | | - array( $baseKey => $base, $middleKey => $middle, $subKey => array_keys( $sub ) ), |
1303 | | - LIST_AND); |
| 1301 | + $conds[] = $this->makeList( |
| 1302 | + array( $baseKey => $base, |
| 1303 | + $middleKey => $middle, |
| 1304 | + $subKey => array_keys( $sub ) ), |
| 1305 | + LIST_AND |
| 1306 | + ); |
1304 | 1307 | } |
1305 | 1308 | } |
1306 | 1309 | } |
Index: branches/iwtransclusion/phase3/includes/EditPage.php |
— | — | @@ -1189,7 +1189,7 @@ |
1190 | 1190 | * near the top, for captchas and the like. |
1191 | 1191 | */ |
1192 | 1192 | function showEditForm( $formCallback=null ) { |
1193 | | - global $wgOut, $wgUser, $wgTitle; |
| 1193 | + global $wgOut, $wgUser, $wgTitle, $wgEnableInterwikiTranscluding, $wgEnableInterwikiTemplatesTracking; |
1194 | 1194 | |
1195 | 1195 | # If $wgTitle is null, that means we're in API mode. |
1196 | 1196 | # Some hook probably called this function without checking |
— | — | @@ -1241,6 +1241,9 @@ |
1242 | 1242 | |
1243 | 1243 | $templates = $this->getTemplates(); |
1244 | 1244 | $formattedtemplates = $sk->formatTemplates( $templates, $this->preview, $this->section != ''); |
| 1245 | + |
| 1246 | + $distantTemplates = $this->getDistantTemplates(); |
| 1247 | + $formattedDistantTemplates = $sk->formatDistantTemplates( $distantTemplates, $this->preview, $this->section != '' ); |
1245 | 1248 | |
1246 | 1249 | $hiddencats = $this->mArticle->getHiddenCategories(); |
1247 | 1250 | $formattedhiddencats = $sk->formatHiddenCategories( $hiddencats ); |
— | — | @@ -1331,6 +1334,21 @@ |
1332 | 1335 | <div class='templatesUsed'> |
1333 | 1336 | {$formattedtemplates} |
1334 | 1337 | </div> |
| 1338 | +HTML |
| 1339 | +); |
| 1340 | + |
| 1341 | + if ( $wgEnableInterwikiTranscluding && $wgEnableInterwikiTemplatesTracking ) { |
| 1342 | + $wgOut->addHTML( <<<HTML |
| 1343 | +{$this->editFormTextAfterTools} |
| 1344 | +<div class='distantTemplatesUsed'> |
| 1345 | +{$formattedDistantTemplates} |
| 1346 | +</div> |
| 1347 | +HTML |
| 1348 | +); |
| 1349 | + } |
| 1350 | + |
| 1351 | + $wgOut->addHTML( <<<HTML |
| 1352 | +{$this->editFormTextAfterTools} |
1335 | 1353 | <div class='hiddencats'> |
1336 | 1354 | {$formattedhiddencats} |
1337 | 1355 | </div> |
— | — | @@ -1949,6 +1967,28 @@ |
1950 | 1968 | return $this->mArticle->getUsedTemplates(); |
1951 | 1969 | } |
1952 | 1970 | } |
| 1971 | + |
| 1972 | + function getDistantTemplates() { |
| 1973 | + global $wgEnableInterwikiTemplatesTracking; |
| 1974 | + if ( !$wgEnableInterwikiTemplatesTracking ) { |
| 1975 | + return array( ); |
| 1976 | + } |
| 1977 | + if ( $this->preview || $this->section != '' ) { |
| 1978 | + $templates = array(); |
| 1979 | + if ( !isset( $this->mParserOutput ) ) return $templates; |
| 1980 | + $templatesList = $this->mParserOutput->getDistantTemplates(); |
| 1981 | + foreach( $templatesList as $prefix => $templatesbyns ) { |
| 1982 | + foreach( $templatesbyns as $ns => $template ) { |
| 1983 | + foreach( array_keys( $template ) as $dbk ) { |
| 1984 | + $templates[] = Title::makeTitle( $ns, $dbk, null, $prefix ); |
| 1985 | + } |
| 1986 | + } |
| 1987 | + } |
| 1988 | + return $templates; |
| 1989 | + } else { |
| 1990 | + return $this->mArticle->getUsedDistantTemplates(); |
| 1991 | + } |
| 1992 | + } |
1953 | 1993 | |
1954 | 1994 | /** |
1955 | 1995 | * Call the stock "user is blocked" page |
Index: branches/iwtransclusion/phase3/includes/OutputPage.php |
— | — | @@ -1895,7 +1895,7 @@ |
1896 | 1896 | * @param $action String: action that was denied or null if unknown |
1897 | 1897 | */ |
1898 | 1898 | public function readOnlyPage( $source = null, $protected = false, $reasons = array(), $action = null ) { |
1899 | | - global $wgUser; |
| 1899 | + global $wgUser, $wgEnableInterwikiTranscluding, $wgEnableInterwikiTemplatesTracking; |
1900 | 1900 | $skin = $wgUser->getSkin(); |
1901 | 1901 | |
1902 | 1902 | $this->setRobotPolicy( 'noindex,nofollow' ); |
— | — | @@ -1945,6 +1945,12 @@ |
1946 | 1946 | {$skin->formatTemplates( $article->getUsedTemplates() )} |
1947 | 1947 | </div> |
1948 | 1948 | " ); |
| 1949 | + if ( $wgEnableInterwikiTranscluding && $wgEnableInterwikiTemplatesTracking ) { |
| 1950 | + $this->addHTML( "<div class='distantTemplatesUsed'> |
| 1951 | +{$skin->formatDistantTemplates( $article->getUsedDistantTemplates( ) )} |
| 1952 | +</div> |
| 1953 | +" ); |
| 1954 | + } |
1949 | 1955 | } |
1950 | 1956 | |
1951 | 1957 | # If the title doesn't exist, it's fairly pointless to print a return |
Index: branches/iwtransclusion/phase3/includes/LinksUpdate.php |
— | — | @@ -128,8 +128,8 @@ |
129 | 129 | $this->getTemplateInsertions( $existing ) ); |
130 | 130 | |
131 | 131 | # Distant template links |
132 | | - global $wgGlobalDB; |
133 | | - if ( $wgGlobalDB ) { |
| 132 | + global $wgEnableInterwikiTemplatesTracking, $wgGlobalDatabase; |
| 133 | + if ( $wgEnableInterwikiTemplatesTracking && $wgGlobalDatabase ) { |
134 | 134 | $existing = $this->getDistantExistingTemplates(); |
135 | 135 | $this->incrSharedTableUpdate( 'globaltemplatelinks', 'gtl', |
136 | 136 | $this->getDistantTemplateDeletions( $existing ), |
— | — | @@ -358,16 +358,14 @@ |
359 | 359 | * @private |
360 | 360 | */ |
361 | 361 | function incrSharedTableUpdate( $table, $prefix, $deletions, $insertions ) { |
362 | | - |
363 | | - global $wgWikiID; |
364 | | - global $wgGlobalDB; |
| 362 | + global $wgEnableInterwikiTemplatesTracking, $wgGlobalDatabase; |
365 | 363 | |
366 | | - if ( $wgGlobalDB ) { |
367 | | - $dbw = wfGetDB( DB_MASTER, array(), $wgGlobalDB ); |
368 | | - $where = array( "{$prefix}_from_wiki" => $wgWikiID, |
| 364 | + if ( $wgEnableInterwikiTemplatesTracking && $wgGlobalDatabase ) { |
| 365 | + $dbw = wfGetDB( DB_MASTER, array(), $wgGlobalDatabase ); |
| 366 | + $where = array( "{$prefix}_from_wiki" => wfWikiID( ), |
369 | 367 | "{$prefix}_from_page" => $this->mId |
370 | 368 | ); |
371 | | - $baseKey = "{$prefix}_to_wiki"; |
| 369 | + $baseKey = "{$prefix}_to_prefix"; |
372 | 370 | $middleKey = "{$prefix}_to_namespace"; |
373 | 371 | |
374 | 372 | $clause = $dbw->makeWhereFrom3d( $deletions, $baseKey, $middleKey, "{$prefix}_to_title" ); |
— | — | @@ -432,18 +430,18 @@ |
433 | 431 | * @private |
434 | 432 | */ |
435 | 433 | function getDistantTemplateInsertions( $existing = array() ) { |
436 | | - global $wgWikiID; |
| 434 | + |
437 | 435 | $arr = array(); |
438 | | - foreach( $this->mDistantTemplates as $wikiid => $templatesToNS ) { |
| 436 | + foreach( $this->mDistantTemplates as $prefix => $templatesToNS ) { |
439 | 437 | foreach( $templatesToNS as $ns => $dbkeys ) { |
440 | | - $diffs = isset( $existing[$wikiid] ) && isset( $existing[$wikiid][$ns] ) ? array_diff_key( $dbkeys, $existing[$wikiid][$ns] ) : $dbkeys; |
| 438 | + $diffs = isset( $existing[$prefix] ) && isset( $existing[$prefix][$ns] ) ? array_diff_key( $dbkeys, $existing[$prefix][$ns] ) : $dbkeys; |
441 | 439 | foreach ( $diffs as $dbk => $id ) { |
442 | 440 | $arr[] = array( |
443 | | - 'gtl_from_wiki' => $wgWikiID, |
| 441 | + 'gtl_from_wiki' => wfWikiID( ), |
444 | 442 | 'gtl_from_page' => $this->mId, |
445 | 443 | 'gtl_from_namespace' => $this->mTitle->getNsText(), |
446 | 444 | 'gtl_from_title' => $this->mTitle->getText(), |
447 | | - 'gtl_to_wiki' => $wikiid, |
| 445 | + 'gtl_to_prefix' => $prefix, |
448 | 446 | 'gtl_to_namespace' => $ns, |
449 | 447 | 'gtl_to_title' => $dbk |
450 | 448 | ); |
— | — | @@ -641,17 +639,17 @@ |
642 | 640 | */ |
643 | 641 | function getDistantTemplateDeletions( $existing ) { |
644 | 642 | $del = array(); |
645 | | - foreach ( $existing as $wikiid => $templatesForNS ) { |
646 | | - if ( isset( $this->mDistantTemplates[$wikiid] ) ) { |
647 | | - $del[$wikiid] = array_diff_key( $existing[$wikiid], $this->mDistantTemplates[$wikiid] ); |
| 643 | + foreach ( $existing as $prefix => $templatesForNS ) { |
| 644 | + if ( isset( $this->mDistantTemplates[$prefix] ) ) { |
| 645 | + $del[$prefix] = array_diff_key( $existing[$prefix], $this->mDistantTemplates[$prefix] ); |
648 | 646 | } else { |
649 | | - $del[$wikiid] = $existing[$wikiid]; |
| 647 | + $del[$prefix] = $existing[$prefix]; |
650 | 648 | } |
651 | 649 | foreach ( $templatesForNS as $ns => $dbkeys ) { |
652 | | - if ( isset( $this->mDistantTemplates[$wikiid][$ns] ) ) { |
653 | | - $del[$wikiid][$ns] = array_diff_key( $existing[$wikiid][$ns], $this->mDistantTemplates[$wikiid][$ns] ); |
| 650 | + if ( isset( $this->mDistantTemplates[$prefix][$ns] ) ) { |
| 651 | + $del[$prefix][$ns] = array_diff_key( $existing[$prefix][$ns], $this->mDistantTemplates[$prefix][$ns] ); |
654 | 652 | } else { |
655 | | - $del[$wikiid][$ns] = $existing[$wikiid][$ns]; |
| 653 | + $del[$prefix][$ns] = $existing[$prefix][$ns]; |
656 | 654 | } |
657 | 655 | } |
658 | 656 | } |
— | — | @@ -760,24 +758,22 @@ |
761 | 759 | * @private |
762 | 760 | */ |
763 | 761 | function getDistantExistingTemplates() { |
764 | | - global $wgWikiID; |
765 | | - global $wgGlobalDB; |
| 762 | + global $wgEnableInterwikiTemplatesTracking, $wgGlobalDatabase; |
766 | 763 | |
767 | 764 | $arr = array(); |
768 | | - if ( $wgGlobalDB ) { |
769 | | - $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDB ); |
770 | | - $res = $dbr->select( 'globaltemplatelinks', array( 'gtl_to_wiki', 'gtl_to_namespace', 'gtl_to_title' ), |
771 | | - array( 'gtl_from_wiki' => $wgWikiID, 'gtl_from_page' => $this->mId ), __METHOD__, $this->mOptions ); |
772 | | - while ( $row = $dbr->fetchObject( $res ) ) { |
773 | | - if ( !isset( $arr[$row->gtl_to_wiki] ) ) { |
774 | | - $arr[$row->gtl_to_wiki] = array(); |
| 765 | + if ( $wgGlobalDatabase ) { |
| 766 | + $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase ); |
| 767 | + $res = $dbr->select( 'globaltemplatelinks', array( 'gtl_to_prefix', 'gtl_to_namespace', 'gtl_to_title' ), |
| 768 | + array( 'gtl_from_wiki' => wfWikiID( ), 'gtl_from_page' => $this->mId ), __METHOD__, $this->mOptions ); |
| 769 | + foreach ( $res as $row ) { |
| 770 | + if ( !isset( $arr[$row->gtl_to_prefix] ) ) { |
| 771 | + $arr[$row->gtl_to_prefix] = array(); |
775 | 772 | } |
776 | | - if ( !isset( $arr[$row->gtl_to_wiki][$row->gtl_to_namespace] ) ) { |
777 | | - $arr[$row->gtl_to_wiki][$row->gtl_to_namespace] = array(); |
| 773 | + if ( !isset( $arr[$row->gtl_to_prefix][$row->gtl_to_namespace] ) ) { |
| 774 | + $arr[$row->gtl_to_prefix][$row->gtl_to_namespace] = array(); |
778 | 775 | } |
779 | | - $arr[$row->gtl_to_wiki][$row->gtl_to_namespace][$row->gtl_to_title] = 1; |
| 776 | + $arr[$row->gtl_to_prefix][$row->gtl_to_namespace][$row->gtl_to_title] = 1; |
780 | 777 | } |
781 | | - $dbr->freeResult( $res ); |
782 | 778 | } |
783 | 779 | return $arr; |
784 | 780 | } |
Index: branches/iwtransclusion/phase3/includes/Title.php |
— | — | @@ -3057,7 +3057,7 @@ |
3058 | 3058 | * @return \type{\mixed} true on success, getUserPermissionsErrors()-like array on failure |
3059 | 3059 | */ |
3060 | 3060 | public function moveTo( &$nt, $auth = true, $reason = '', $createRedirect = true ) { |
3061 | | - global $wgContLang, $wgGlobalDB, $wgWikiID; |
| 3061 | + global $wgContLang, $wgEnableInterwikiTemplatesTracking, $wgGlobalDatabase; |
3062 | 3062 | |
3063 | 3063 | $err = $this->isValidMoveOperation( $nt, $auth, $reason ); |
3064 | 3064 | if ( is_array( $err ) ) { |
— | — | @@ -3106,8 +3106,8 @@ |
3107 | 3107 | array( 'cl_from' => $pageid ), |
3108 | 3108 | __METHOD__ ); |
3109 | 3109 | |
3110 | | - if ( $wgGlobalDB ) { |
3111 | | - $dbw2 = wfGetDB( DB_MASTER, array(), $wgGlobalDB ); |
| 3110 | + if ( $wgEnableInterwikiTemplatesTracking && $wgGlobalDatabase ) { |
| 3111 | + $dbw2 = wfGetDB( DB_MASTER, array(), $wgGlobalDatabase ); |
3112 | 3112 | $dbw2->update( 'globaltemplatelinks', |
3113 | 3113 | array( 'gtl_from_namespace' => $nt->getNsText(), |
3114 | 3114 | 'gtl_from_title' => $nt->getText() ), |
— | — | @@ -3207,7 +3207,7 @@ |
3208 | 3208 | * Ignored if the user doesn't have the suppressredirect right |
3209 | 3209 | */ |
3210 | 3210 | private function moveOverExistingRedirect( &$nt, $reason = '', $createRedirect = true ) { |
3211 | | - global $wgUseSquid, $wgUser, $wgContLang, $wgWikiID, $wgGlobalDB; |
| 3211 | + global $wgUseSquid, $wgUser, $wgContLang, $wgEnableInterwikiTemplatesTracking, $wgGlobalDatabase; |
3212 | 3212 | |
3213 | 3213 | $comment = wfMsgForContent( '1movedto2_redir', $this->getPrefixedText(), $nt->getPrefixedText() ); |
3214 | 3214 | |
— | — | @@ -3247,10 +3247,10 @@ |
3248 | 3248 | $dbw->delete( 'langlinks', array( 'll_from' => $newid ), __METHOD__ ); |
3249 | 3249 | $dbw->delete( 'redirect', array( 'rd_from' => $newid ), __METHOD__ ); |
3250 | 3250 | |
3251 | | - if ( $wgGlobalDB ) { |
3252 | | - $dbw2 = wfGetDB( DB_MASTER, array(), $wgGlobalDB ); |
| 3251 | + if ( $wgEnableInterwikiTemplatesTracking && $wgGlobalDatabase ) { |
| 3252 | + $dbw2 = wfGetDB( DB_MASTER, array(), $wgGlobalDatabase ); |
3253 | 3253 | $dbw2->delete( 'globaltemplatelinks', |
3254 | | - array( 'gtl_from_wiki' => $wgWikiID, |
| 3254 | + array( 'gtl_from_wiki' => wfWikiID( ), |
3255 | 3255 | 'gtl_from_page' => $newid ), |
3256 | 3256 | __METHOD__ ); |
3257 | 3257 | } |
Index: branches/iwtransclusion/phase3/languages/messages/MessagesEn.php |
— | — | @@ -1350,6 +1350,9 @@ |
1351 | 1351 | 'templatesused' => '{{PLURAL:$1|Template|Templates}} used on this page:', |
1352 | 1352 | 'templatesusedpreview' => '{{PLURAL:$1|Template|Templates}} used in this preview:', |
1353 | 1353 | 'templatesusedsection' => '{{PLURAL:$1|Template|Templates}} used in this section:', |
| 1354 | +'distanttemplatesused' => 'Distant {{PLURAL:$1|template|templates}} used on this page:', |
| 1355 | +'distanttemplatesusedpreview' => 'Distant {{PLURAL:$1|template|templates}} used in this preview:', |
| 1356 | +'distanttemplatesusedsection' => 'Distant {{PLURAL:$1|template|templates}} used in this section:', |
1354 | 1357 | 'template-protected' => '(protected)', |
1355 | 1358 | 'template-semiprotected' => '(semi-protected)', |
1356 | 1359 | 'hiddencategories' => 'This page is a member of {{PLURAL:$1|1 hidden category|$1 hidden categories}}:', |