Index: branches/iwtransclusion/phase3v3/includes/parser/Parser.php |
— | — | @@ -3267,14 +3267,14 @@ |
3268 | 3268 | $found = true; |
3269 | 3269 | } |
3270 | 3270 | } elseif ( $wgEnableInterwikiTranscluding && $title->isTrans() ) { |
3271 | | - |
| 3271 | + |
3272 | 3272 | $text = Interwiki::interwikiTransclude( $title ); |
3273 | 3273 | $this->registerDistantTemplate( $title ); |
3274 | | - |
| 3274 | + |
3275 | 3275 | if ( $wgEnableInterwikiTemplatesTracking ) { |
3276 | 3276 | $this->registerDistantTemplate( $title ); |
3277 | 3277 | } |
3278 | | - |
| 3278 | + |
3279 | 3279 | if ( $text !== false ) { |
3280 | 3280 | # Preprocess it like a template |
3281 | 3281 | $text = $this->preprocessToDom( $text, self::PTD_FOR_INCLUSION ); |
— | — | @@ -3427,28 +3427,11 @@ |
3428 | 3428 | } |
3429 | 3429 | return array( $text, $finalTitle ); |
3430 | 3430 | } |
3431 | | - |
| 3431 | + |
3432 | 3432 | /** |
3433 | 3433 | * Register a distant template as used |
3434 | 3434 | */ |
3435 | 3435 | function registerDistantTemplate( $title ) { |
3436 | | - $templateCb = array( 'Parser', 'distantTemplateCallback' ); |
3437 | | - $stuff = call_user_func( $templateCb, $title, $this ); |
3438 | | - $text = $stuff['text']; |
3439 | | - $finalTitle = isset( $stuff['finalTitle'] ) ? $stuff['finalTitle'] : $title; |
3440 | | - if ( isset( $stuff['deps'] ) ) { |
3441 | | - foreach ( $stuff['deps'] as $dep ) { |
3442 | | - $this->mOutput->addDistantTemplate( $dep['title'], $dep['page_id'], $dep['rev_id'] ); |
3443 | | - } |
3444 | | - } |
3445 | | - } |
3446 | | - |
3447 | | - /** |
3448 | | - * Fetch the unparsed text of a template and register a reference to it. |
3449 | | - * @param Title $title |
3450 | | - * @return mixed string or false |
3451 | | - */ |
3452 | | - function registerDistantTemplate( $title ) { |
3453 | 3436 | $stuff = Parser::distantTemplateCallback( $title, $this ); |
3454 | 3437 | $text = $stuff['text']; |
3455 | 3438 | $finalTitle = isset( $stuff['finalTitle'] ) ? $stuff['finalTitle'] : $title; |
— | — | @@ -3549,7 +3532,7 @@ |
3550 | 3533 | 'rev_id' => $rev_id ); |
3551 | 3534 | |
3552 | 3535 | $finalTitle = $title; |
3553 | | - |
| 3536 | + |
3554 | 3537 | return array( |
3555 | 3538 | 'text' => $text, |
3556 | 3539 | 'finalTitle' => $finalTitle, |
— | — | @@ -4137,10 +4120,10 @@ |
4138 | 4121 | # split up and insert constructed headlines |
4139 | 4122 | $blocks = preg_split( '/<H[1-6].*?' . '>.*?<\/H[1-6]>/i', $text ); |
4140 | 4123 | $i = 0; |
4141 | | - |
| 4124 | + |
4142 | 4125 | // build an array of document sections |
4143 | 4126 | $sections = array(); |
4144 | | - foreach ( $blocks as $block ) { |
| 4127 | + foreach ( $blocks as $block ) { |
4145 | 4128 | // $head is zero-based, sections aren't. |
4146 | 4129 | if ( empty( $head[$i - 1] ) ) { |
4147 | 4130 | $sections[$i] = $block; |
— | — | @@ -4159,7 +4142,7 @@ |
4160 | 4143 | * $showEditLinks : boolean describing whether this section has an edit link |
4161 | 4144 | */ |
4162 | 4145 | wfRunHooks( 'ParserSectionCreate', array( $this, $i, &$sections[$i], $showEditLink ) ); |
4163 | | - |
| 4146 | + |
4164 | 4147 | $i++; |
4165 | 4148 | } |
4166 | 4149 | |
— | — | @@ -4168,9 +4151,9 @@ |
4169 | 4152 | // Top anchor now in skin |
4170 | 4153 | $sections[0] = $sections[0] . $toc . "\n"; |
4171 | 4154 | } |
4172 | | - |
| 4155 | + |
4173 | 4156 | $full .= join( '', $sections ); |
4174 | | - |
| 4157 | + |
4175 | 4158 | if ( $this->mForceTocPosition ) { |
4176 | 4159 | return str_replace( '<!--MWTOC-->', $toc, $full ); |
4177 | 4160 | } else { |
Index: branches/iwtransclusion/phase3v3/includes/Linker.php |
— | — | @@ -1654,7 +1654,7 @@ |
1655 | 1655 | * @param $section Boolean: whether this is for a section edit |
1656 | 1656 | * @return String: HTML output |
1657 | 1657 | */ |
1658 | | - public function formatDistantTemplates( $templates, $preview = false, $section = false ) { |
| 1658 | + public static function formatDistantTemplates( $templates, $preview = false, $section = false ) { |
1659 | 1659 | wfProfileIn( __METHOD__ ); |
1660 | 1660 | |
1661 | 1661 | $outText = ''; |
— | — | @@ -1673,7 +1673,7 @@ |
1674 | 1674 | |
1675 | 1675 | usort( $templates, array( 'Title', 'compare' ) ); |
1676 | 1676 | foreach ( $templates as $titleObj ) { |
1677 | | - $outText .= '<li>' . $this->link( $titleObj ) . '</li>'; |
| 1677 | + $outText .= '<li>' . self::link( $titleObj ) . '</li>'; |
1678 | 1678 | } |
1679 | 1679 | $outText .= '</ul>'; |
1680 | 1680 | } |
Index: branches/iwtransclusion/phase3v3/includes/EditPage.php |
— | — | @@ -1320,7 +1320,7 @@ |
1321 | 1321 | * during form output near the top, for captchas and the like. |
1322 | 1322 | */ |
1323 | 1323 | function showEditForm( $formCallback=null ) { |
1324 | | - global $wgOut, $wgUser, $wgTitle, $wgEnableInterwikiTranscluding, $wgEnableInterwikiTemplatesTracking; |
| 1324 | + global $wgOut, $wgUser, $wgEnableInterwikiTranscluding, $wgEnableInterwikiTemplatesTracking; |
1325 | 1325 | |
1326 | 1326 | wfProfileIn( __METHOD__ ); |
1327 | 1327 | |
— | — | @@ -1354,7 +1354,6 @@ |
1355 | 1355 | $toolbar = ''; |
1356 | 1356 | } |
1357 | 1357 | |
1358 | | - |
1359 | 1358 | $wgOut->addHTML( $this->editFormPageTop ); |
1360 | 1359 | |
1361 | 1360 | if ( $wgUser->getOption( 'previewontop' ) ) { |
— | — | @@ -1365,9 +1364,9 @@ |
1366 | 1365 | |
1367 | 1366 | $templates = $this->getTemplates(); |
1368 | 1367 | $formattedtemplates = Linker::formatTemplates( $templates, $this->preview, $this->section != ''); |
1369 | | - |
| 1368 | + |
1370 | 1369 | $distantTemplates = $this->getDistantTemplates(); |
1371 | | - $formattedDistantTemplates = $sk->formatDistantTemplates( $distantTemplates, $this->preview, $this->section != '' ); |
| 1370 | + $formattedDistantTemplates = Linker::formatDistantTemplates( $distantTemplates, $this->preview, $this->section != '' ); |
1372 | 1371 | |
1373 | 1372 | $hiddencats = $this->mArticle->getHiddenCategories(); |
1374 | 1373 | $formattedhiddencats = Linker::formatHiddenCategories( $hiddencats ); |
— | — | @@ -2137,7 +2136,7 @@ |
2138 | 2137 | return $this->mArticle->getUsedTemplates(); |
2139 | 2138 | } |
2140 | 2139 | } |
2141 | | - |
| 2140 | + |
2142 | 2141 | function getDistantTemplates() { |
2143 | 2142 | global $wgEnableInterwikiTemplatesTracking; |
2144 | 2143 | if ( !$wgEnableInterwikiTemplatesTracking ) { |
Index: branches/iwtransclusion/phase3v3/includes/LinksUpdate.php |
— | — | @@ -153,7 +153,7 @@ |
154 | 154 | $existing = $this->getExistingTemplates(); |
155 | 155 | $this->incrTableUpdate( 'templatelinks', 'tl', $this->getTemplateDeletions( $existing ), |
156 | 156 | $this->getTemplateInsertions( $existing ) ); |
157 | | - |
| 157 | + |
158 | 158 | # Distant template links |
159 | 159 | global $wgGlobalDB; |
160 | 160 | if ( $wgGlobalDB ) { |
— | — | @@ -383,7 +383,7 @@ |
384 | 384 | $this->mDb->insert( 'globalinterwiki', $insertions['globalinterwiki'], __METHOD__, 'IGNORE' ); |
385 | 385 | } |
386 | 386 | } |
387 | | - |
| 387 | + |
388 | 388 | /** |
389 | 389 | * Update a shared table by doing a delete query then an insert query |
390 | 390 | * @private |
— | — | @@ -392,7 +392,7 @@ |
393 | 393 | |
394 | 394 | global $wgWikiID; |
395 | 395 | global $wgGlobalDB; |
396 | | - |
| 396 | + |
397 | 397 | if ( $wgGlobalDB ) { |
398 | 398 | $dbw = wfGetDB( DB_MASTER, array(), $wgGlobalDB ); |
399 | 399 | $where = array( "{$prefix}_from_wiki" => $wgWikiID, |
— | — | @@ -400,14 +400,14 @@ |
401 | 401 | ); |
402 | 402 | $baseKey = "{$prefix}_to_wiki"; |
403 | 403 | $middleKey = "{$prefix}_to_namespace"; |
404 | | - |
| 404 | + |
405 | 405 | $clause = $dbw->makeWhereFrom3d( $deletions, $baseKey, $middleKey, "{$prefix}_to_title" ); |
406 | 406 | if ( $clause ) { |
407 | 407 | $where[] = $clause; |
408 | 408 | } else { |
409 | 409 | $where = false; |
410 | 410 | } |
411 | | - |
| 411 | + |
412 | 412 | if ( $where ) { |
413 | 413 | $dbw->delete( $table, $where, __METHOD__ ); |
414 | 414 | } |
— | — | @@ -457,7 +457,7 @@ |
458 | 458 | } |
459 | 459 | return $arr; |
460 | 460 | } |
461 | | - |
| 461 | + |
462 | 462 | /** |
463 | 463 | * Get an array of distant template insertions. Like getLinkInsertions() |
464 | 464 | * @private |
— | — | @@ -467,8 +467,10 @@ |
468 | 468 | $arr = array(); |
469 | 469 | foreach( $this->mDistantTemplates as $wikiid => $templatesToNS ) { |
470 | 470 | foreach( $templatesToNS as $ns => $dbkeys ) { |
471 | | - $diffs = isset( $existing[$wikiid] ) && isset( $existing[$wikiid][$ns] ) ? array_diff_key( $dbkeys, $existing[$wikiid][$ns] ) : $dbkeys; |
472 | | - $interwiki = Interwiki::fetch( $prefix ); |
| 471 | + $diffs = isset( $existing[$wikiid] ) && isset( $existing[$wikiid][$ns] ) |
| 472 | + ? array_diff_key( $dbkeys, $existing[$wikiid][$ns] ) |
| 473 | + : $dbkeys; |
| 474 | + $interwiki = Interwiki::fetch( $wikiid ); |
473 | 475 | $wikiid = $interwiki->getWikiID(); |
474 | 476 | foreach ( $diffs as $dbk => $id ) { |
475 | 477 | $arr['globaltemplatelinks'][] = array( |
— | — | @@ -660,7 +662,7 @@ |
661 | 663 | } |
662 | 664 | return $del; |
663 | 665 | } |
664 | | - |
| 666 | + |
665 | 667 | /** |
666 | 668 | * Given an array of existing templates, returns those templates which are not in $this |
667 | 669 | * and thus should be deleted. |
— | — | @@ -779,7 +781,7 @@ |
780 | 782 | } |
781 | 783 | return $arr; |
782 | 784 | } |
783 | | - |
| 785 | + |
784 | 786 | /** |
785 | 787 | * Get an array of existing distant templates, as a 3-D array |
786 | 788 | * @private |
— | — | @@ -787,7 +789,7 @@ |
788 | 790 | function getDistantExistingTemplates() { |
789 | 791 | global $wgWikiID; |
790 | 792 | global $wgGlobalDB; |
791 | | - |
| 793 | + |
792 | 794 | $arr = array(); |
793 | 795 | if ( $wgGlobalDB ) { |
794 | 796 | $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDB ); |
Index: branches/iwtransclusion/phase3v3/includes/Revision.php |
— | — | @@ -156,27 +156,27 @@ |
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
160 | | - * Stores the origin wiki of a revision in case it is a foreign wiki |
| 160 | + * Stores the origin wiki of a revision in case it is a foreign wiki |
161 | 161 | */ |
162 | 162 | function setWikiID( $wikiID ) { |
163 | 163 | $this->mWikiID = $wikiID; |
164 | 164 | } |
165 | | - |
| 165 | + |
166 | 166 | /** |
167 | 167 | * Load the current revision of a given page of a foreign wiki. |
168 | | - * The WikiID is stored for further use, such as loadText() and getTimestampFromId() |
| 168 | + * The WikiID is stored for further use, such as loadText() and getTimestampFromId() |
169 | 169 | */ |
170 | 170 | public static function loadFromTitleForeignWiki( $wikiID, $title ) { |
171 | 171 | $dbr = wfGetDB( DB_SLAVE, array(), $wikiID ); |
172 | | - |
| 172 | + |
173 | 173 | $revision = self::loadFromTitle( $dbr, $title ); |
174 | | - |
| 174 | + |
175 | 175 | if( $revision ) { |
176 | 176 | $revision->setWikiID( $wikiID ); |
177 | 177 | } |
178 | | - |
| 178 | + |
179 | 179 | return $revision; |
180 | | - |
| 180 | + |
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
— | — | @@ -463,7 +463,7 @@ |
464 | 464 | return $this->mTitle; |
465 | 465 | } |
466 | 466 | $dbr = wfGetDB( DB_SLAVE, array(), $this->mWikiID ); |
467 | | - |
| 467 | + |
468 | 468 | $row = $dbr->selectRow( |
469 | 469 | array( 'page', 'revision' ), |
470 | 470 | array( 'page_namespace', 'page_title' ), |
— | — | @@ -1081,7 +1081,8 @@ |
1082 | 1082 | * @return String |
1083 | 1083 | */ |
1084 | 1084 | static function getTimestampFromId( $title, $id ) { |
1085 | | - $dbr = wfGetDB( DB_SLAVE, array(), $this->mWikiID ); |
| 1085 | + $wikiId = wfWikiID(); |
| 1086 | + $dbr = wfGetDB( DB_SLAVE, array(), $wikiId ); |
1086 | 1087 | // Casting fix for DB2 |
1087 | 1088 | if ( $id == '' ) { |
1088 | 1089 | $id = 0; |
— | — | @@ -1091,7 +1092,7 @@ |
1092 | 1093 | $timestamp = $dbr->selectField( 'revision', 'rev_timestamp', $conds, __METHOD__ ); |
1093 | 1094 | if ( $timestamp === false && wfGetLB()->getServerCount() > 1 ) { |
1094 | 1095 | # Not in slave, try master |
1095 | | - $dbw = wfGetDB( DB_MASTER, array(), $this->mWikiID ); |
| 1096 | + $dbw = wfGetDB( DB_MASTER, array(), $wikiId ); |
1096 | 1097 | $timestamp = $dbw->selectField( 'revision', 'rev_timestamp', $conds, __METHOD__ ); |
1097 | 1098 | } |
1098 | 1099 | return wfTimestamp( TS_MW, $timestamp ); |
Index: branches/iwtransclusion/phase3v3/includes/WikiPage.php |
— | — | @@ -1571,7 +1571,7 @@ |
1572 | 1572 | public function doDeleteArticle( |
1573 | 1573 | $reason, $suppress = false, $id = 0, $commit = true, &$error = '', User $user = null |
1574 | 1574 | ) { |
1575 | | - global $wgDeferredUpdateList, $wgUseTrackbacks, $wgEnableInterwikiTemplatesTracking, $wgGlobalDatabase; |
| 1575 | + global $wgDeferredUpdateList, $wgUseTrackbacks, $wgEnableInterwikiTemplatesTracking, $wgGlobalDatabase, $wgUser; |
1576 | 1576 | $user = is_null( $user ) ? $wgUser : $user; |
1577 | 1577 | |
1578 | 1578 | wfDebug( __METHOD__ . "\n" ); |
— | — | @@ -2202,7 +2202,7 @@ |
2203 | 2203 | $title->deleteTitleProtection(); |
2204 | 2204 | |
2205 | 2205 | # Invalidate caches of distant articles which transclude this page |
2206 | | - $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'globaltemplatelinks' ) |
| 2206 | + $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'globaltemplatelinks' ); |
2207 | 2207 | } |
2208 | 2208 | |
2209 | 2209 | /** |
— | — | @@ -2248,7 +2248,7 @@ |
2249 | 2249 | |
2250 | 2250 | # Image redirects |
2251 | 2251 | RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect( $title ); |
2252 | | - |
| 2252 | + |
2253 | 2253 | # Invalidate caches of distant articles which transclude this page |
2254 | 2254 | $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'globaltemplatelinks' ); |
2255 | 2255 | } |
— | — | @@ -2264,7 +2264,7 @@ |
2265 | 2265 | |
2266 | 2266 | // Invalidate caches of articles which include this page |
2267 | 2267 | $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'templatelinks' ); |
2268 | | - |
| 2268 | + |
2269 | 2269 | // Invalidate caches of distant articles which transclude this page |
2270 | 2270 | $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'globaltemplatelinks' ); |
2271 | 2271 | |
— | — | @@ -2317,22 +2317,22 @@ |
2318 | 2318 | */ |
2319 | 2319 | public function getUsedDistantTemplates() { |
2320 | 2320 | global $wgGlobalDatabase; |
2321 | | - |
| 2321 | + |
2322 | 2322 | $result = array(); |
2323 | | - |
| 2323 | + |
2324 | 2324 | if ( $wgGlobalDatabase ) { |
2325 | 2325 | $id = $this->mTitle->getArticleID(); |
2326 | 2326 | |
2327 | 2327 | if ( $id == 0 ) { |
2328 | 2328 | return array(); |
2329 | 2329 | } |
2330 | | - |
| 2330 | + |
2331 | 2331 | $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase ); |
2332 | 2332 | $res = $dbr->select( 'globaltemplatelinks', |
2333 | 2333 | array( 'gtl_to_prefix', 'gtl_to_namespace', 'gtl_to_title' ), |
2334 | 2334 | array( 'gtl_from_wiki' => wfWikiID( ), 'gtl_from_page' => $id ), |
2335 | 2335 | __METHOD__ ); |
2336 | | - |
| 2336 | + |
2337 | 2337 | if ( $res !== false ) { |
2338 | 2338 | foreach ( $res as $row ) { |
2339 | 2339 | $result[] = Title::makeTitle( $row->gtl_to_namespace, $row->gtl_to_title, null, $row->gtl_to_prefix ); |