r93007 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93006‎ | r93007 | r93008 >
Date:19:13, 24 July 2011
Author:reedy
Status:ok
Tags:
Comment:
Fix a few syntax/similar errors from manual merging etc
Modified paths:
  • /branches/iwtransclusion/phase3v3/includes/EditPage.php (modified) (history)
  • /branches/iwtransclusion/phase3v3/includes/Linker.php (modified) (history)
  • /branches/iwtransclusion/phase3v3/includes/LinksUpdate.php (modified) (history)
  • /branches/iwtransclusion/phase3v3/includes/Revision.php (modified) (history)
  • /branches/iwtransclusion/phase3v3/includes/WikiPage.php (modified) (history)
  • /branches/iwtransclusion/phase3v3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: branches/iwtransclusion/phase3v3/includes/parser/Parser.php
@@ -3267,14 +3267,14 @@
32683268 $found = true;
32693269 }
32703270 } elseif ( $wgEnableInterwikiTranscluding && $title->isTrans() ) {
3271 -
 3271+
32723272 $text = Interwiki::interwikiTransclude( $title );
32733273 $this->registerDistantTemplate( $title );
3274 -
 3274+
32753275 if ( $wgEnableInterwikiTemplatesTracking ) {
32763276 $this->registerDistantTemplate( $title );
32773277 }
3278 -
 3278+
32793279 if ( $text !== false ) {
32803280 # Preprocess it like a template
32813281 $text = $this->preprocessToDom( $text, self::PTD_FOR_INCLUSION );
@@ -3427,28 +3427,11 @@
34283428 }
34293429 return array( $text, $finalTitle );
34303430 }
3431 -
 3431+
34323432 /**
34333433 * Register a distant template as used
34343434 */
34353435 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 ) {
34533436 $stuff = Parser::distantTemplateCallback( $title, $this );
34543437 $text = $stuff['text'];
34553438 $finalTitle = isset( $stuff['finalTitle'] ) ? $stuff['finalTitle'] : $title;
@@ -3549,7 +3532,7 @@
35503533 'rev_id' => $rev_id );
35513534
35523535 $finalTitle = $title;
3553 -
 3536+
35543537 return array(
35553538 'text' => $text,
35563539 'finalTitle' => $finalTitle,
@@ -4137,10 +4120,10 @@
41384121 # split up and insert constructed headlines
41394122 $blocks = preg_split( '/<H[1-6].*?' . '>.*?<\/H[1-6]>/i', $text );
41404123 $i = 0;
4141 -
 4124+
41424125 // build an array of document sections
41434126 $sections = array();
4144 - foreach ( $blocks as $block ) {
 4127+ foreach ( $blocks as $block ) {
41454128 // $head is zero-based, sections aren't.
41464129 if ( empty( $head[$i - 1] ) ) {
41474130 $sections[$i] = $block;
@@ -4159,7 +4142,7 @@
41604143 * $showEditLinks : boolean describing whether this section has an edit link
41614144 */
41624145 wfRunHooks( 'ParserSectionCreate', array( $this, $i, &$sections[$i], $showEditLink ) );
4163 -
 4146+
41644147 $i++;
41654148 }
41664149
@@ -4168,9 +4151,9 @@
41694152 // Top anchor now in skin
41704153 $sections[0] = $sections[0] . $toc . "\n";
41714154 }
4172 -
 4155+
41734156 $full .= join( '', $sections );
4174 -
 4157+
41754158 if ( $this->mForceTocPosition ) {
41764159 return str_replace( '<!--MWTOC-->', $toc, $full );
41774160 } else {
Index: branches/iwtransclusion/phase3v3/includes/Linker.php
@@ -1654,7 +1654,7 @@
16551655 * @param $section Boolean: whether this is for a section edit
16561656 * @return String: HTML output
16571657 */
1658 - public function formatDistantTemplates( $templates, $preview = false, $section = false ) {
 1658+ public static function formatDistantTemplates( $templates, $preview = false, $section = false ) {
16591659 wfProfileIn( __METHOD__ );
16601660
16611661 $outText = '';
@@ -1673,7 +1673,7 @@
16741674
16751675 usort( $templates, array( 'Title', 'compare' ) );
16761676 foreach ( $templates as $titleObj ) {
1677 - $outText .= '<li>' . $this->link( $titleObj ) . '</li>';
 1677+ $outText .= '<li>' . self::link( $titleObj ) . '</li>';
16781678 }
16791679 $outText .= '</ul>';
16801680 }
Index: branches/iwtransclusion/phase3v3/includes/EditPage.php
@@ -1320,7 +1320,7 @@
13211321 * during form output near the top, for captchas and the like.
13221322 */
13231323 function showEditForm( $formCallback=null ) {
1324 - global $wgOut, $wgUser, $wgTitle, $wgEnableInterwikiTranscluding, $wgEnableInterwikiTemplatesTracking;
 1324+ global $wgOut, $wgUser, $wgEnableInterwikiTranscluding, $wgEnableInterwikiTemplatesTracking;
13251325
13261326 wfProfileIn( __METHOD__ );
13271327
@@ -1354,7 +1354,6 @@
13551355 $toolbar = '';
13561356 }
13571357
1358 -
13591358 $wgOut->addHTML( $this->editFormPageTop );
13601359
13611360 if ( $wgUser->getOption( 'previewontop' ) ) {
@@ -1365,9 +1364,9 @@
13661365
13671366 $templates = $this->getTemplates();
13681367 $formattedtemplates = Linker::formatTemplates( $templates, $this->preview, $this->section != '');
1369 -
 1368+
13701369 $distantTemplates = $this->getDistantTemplates();
1371 - $formattedDistantTemplates = $sk->formatDistantTemplates( $distantTemplates, $this->preview, $this->section != '' );
 1370+ $formattedDistantTemplates = Linker::formatDistantTemplates( $distantTemplates, $this->preview, $this->section != '' );
13721371
13731372 $hiddencats = $this->mArticle->getHiddenCategories();
13741373 $formattedhiddencats = Linker::formatHiddenCategories( $hiddencats );
@@ -2137,7 +2136,7 @@
21382137 return $this->mArticle->getUsedTemplates();
21392138 }
21402139 }
2141 -
 2140+
21422141 function getDistantTemplates() {
21432142 global $wgEnableInterwikiTemplatesTracking;
21442143 if ( !$wgEnableInterwikiTemplatesTracking ) {
Index: branches/iwtransclusion/phase3v3/includes/LinksUpdate.php
@@ -153,7 +153,7 @@
154154 $existing = $this->getExistingTemplates();
155155 $this->incrTableUpdate( 'templatelinks', 'tl', $this->getTemplateDeletions( $existing ),
156156 $this->getTemplateInsertions( $existing ) );
157 -
 157+
158158 # Distant template links
159159 global $wgGlobalDB;
160160 if ( $wgGlobalDB ) {
@@ -383,7 +383,7 @@
384384 $this->mDb->insert( 'globalinterwiki', $insertions['globalinterwiki'], __METHOD__, 'IGNORE' );
385385 }
386386 }
387 -
 387+
388388 /**
389389 * Update a shared table by doing a delete query then an insert query
390390 * @private
@@ -392,7 +392,7 @@
393393
394394 global $wgWikiID;
395395 global $wgGlobalDB;
396 -
 396+
397397 if ( $wgGlobalDB ) {
398398 $dbw = wfGetDB( DB_MASTER, array(), $wgGlobalDB );
399399 $where = array( "{$prefix}_from_wiki" => $wgWikiID,
@@ -400,14 +400,14 @@
401401 );
402402 $baseKey = "{$prefix}_to_wiki";
403403 $middleKey = "{$prefix}_to_namespace";
404 -
 404+
405405 $clause = $dbw->makeWhereFrom3d( $deletions, $baseKey, $middleKey, "{$prefix}_to_title" );
406406 if ( $clause ) {
407407 $where[] = $clause;
408408 } else {
409409 $where = false;
410410 }
411 -
 411+
412412 if ( $where ) {
413413 $dbw->delete( $table, $where, __METHOD__ );
414414 }
@@ -457,7 +457,7 @@
458458 }
459459 return $arr;
460460 }
461 -
 461+
462462 /**
463463 * Get an array of distant template insertions. Like getLinkInsertions()
464464 * @private
@@ -467,8 +467,10 @@
468468 $arr = array();
469469 foreach( $this->mDistantTemplates as $wikiid => $templatesToNS ) {
470470 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 );
473475 $wikiid = $interwiki->getWikiID();
474476 foreach ( $diffs as $dbk => $id ) {
475477 $arr['globaltemplatelinks'][] = array(
@@ -660,7 +662,7 @@
661663 }
662664 return $del;
663665 }
664 -
 666+
665667 /**
666668 * Given an array of existing templates, returns those templates which are not in $this
667669 * and thus should be deleted.
@@ -779,7 +781,7 @@
780782 }
781783 return $arr;
782784 }
783 -
 785+
784786 /**
785787 * Get an array of existing distant templates, as a 3-D array
786788 * @private
@@ -787,7 +789,7 @@
788790 function getDistantExistingTemplates() {
789791 global $wgWikiID;
790792 global $wgGlobalDB;
791 -
 793+
792794 $arr = array();
793795 if ( $wgGlobalDB ) {
794796 $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDB );
Index: branches/iwtransclusion/phase3v3/includes/Revision.php
@@ -156,27 +156,27 @@
157157 }
158158
159159 /**
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
161161 */
162162 function setWikiID( $wikiID ) {
163163 $this->mWikiID = $wikiID;
164164 }
165 -
 165+
166166 /**
167167 * 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()
169169 */
170170 public static function loadFromTitleForeignWiki( $wikiID, $title ) {
171171 $dbr = wfGetDB( DB_SLAVE, array(), $wikiID );
172 -
 172+
173173 $revision = self::loadFromTitle( $dbr, $title );
174 -
 174+
175175 if( $revision ) {
176176 $revision->setWikiID( $wikiID );
177177 }
178 -
 178+
179179 return $revision;
180 -
 180+
181181 }
182182
183183 /**
@@ -463,7 +463,7 @@
464464 return $this->mTitle;
465465 }
466466 $dbr = wfGetDB( DB_SLAVE, array(), $this->mWikiID );
467 -
 467+
468468 $row = $dbr->selectRow(
469469 array( 'page', 'revision' ),
470470 array( 'page_namespace', 'page_title' ),
@@ -1081,7 +1081,8 @@
10821082 * @return String
10831083 */
10841084 static function getTimestampFromId( $title, $id ) {
1085 - $dbr = wfGetDB( DB_SLAVE, array(), $this->mWikiID );
 1085+ $wikiId = wfWikiID();
 1086+ $dbr = wfGetDB( DB_SLAVE, array(), $wikiId );
10861087 // Casting fix for DB2
10871088 if ( $id == '' ) {
10881089 $id = 0;
@@ -1091,7 +1092,7 @@
10921093 $timestamp = $dbr->selectField( 'revision', 'rev_timestamp', $conds, __METHOD__ );
10931094 if ( $timestamp === false && wfGetLB()->getServerCount() > 1 ) {
10941095 # Not in slave, try master
1095 - $dbw = wfGetDB( DB_MASTER, array(), $this->mWikiID );
 1096+ $dbw = wfGetDB( DB_MASTER, array(), $wikiId );
10961097 $timestamp = $dbw->selectField( 'revision', 'rev_timestamp', $conds, __METHOD__ );
10971098 }
10981099 return wfTimestamp( TS_MW, $timestamp );
Index: branches/iwtransclusion/phase3v3/includes/WikiPage.php
@@ -1571,7 +1571,7 @@
15721572 public function doDeleteArticle(
15731573 $reason, $suppress = false, $id = 0, $commit = true, &$error = '', User $user = null
15741574 ) {
1575 - global $wgDeferredUpdateList, $wgUseTrackbacks, $wgEnableInterwikiTemplatesTracking, $wgGlobalDatabase;
 1575+ global $wgDeferredUpdateList, $wgUseTrackbacks, $wgEnableInterwikiTemplatesTracking, $wgGlobalDatabase, $wgUser;
15761576 $user = is_null( $user ) ? $wgUser : $user;
15771577
15781578 wfDebug( __METHOD__ . "\n" );
@@ -2202,7 +2202,7 @@
22032203 $title->deleteTitleProtection();
22042204
22052205 # Invalidate caches of distant articles which transclude this page
2206 - $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'globaltemplatelinks' )
 2206+ $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'globaltemplatelinks' );
22072207 }
22082208
22092209 /**
@@ -2248,7 +2248,7 @@
22492249
22502250 # Image redirects
22512251 RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect( $title );
2252 -
 2252+
22532253 # Invalidate caches of distant articles which transclude this page
22542254 $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'globaltemplatelinks' );
22552255 }
@@ -2264,7 +2264,7 @@
22652265
22662266 // Invalidate caches of articles which include this page
22672267 $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'templatelinks' );
2268 -
 2268+
22692269 // Invalidate caches of distant articles which transclude this page
22702270 $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'globaltemplatelinks' );
22712271
@@ -2317,22 +2317,22 @@
23182318 */
23192319 public function getUsedDistantTemplates() {
23202320 global $wgGlobalDatabase;
2321 -
 2321+
23222322 $result = array();
2323 -
 2323+
23242324 if ( $wgGlobalDatabase ) {
23252325 $id = $this->mTitle->getArticleID();
23262326
23272327 if ( $id == 0 ) {
23282328 return array();
23292329 }
2330 -
 2330+
23312331 $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase );
23322332 $res = $dbr->select( 'globaltemplatelinks',
23332333 array( 'gtl_to_prefix', 'gtl_to_namespace', 'gtl_to_title' ),
23342334 array( 'gtl_from_wiki' => wfWikiID( ), 'gtl_from_page' => $id ),
23352335 __METHOD__ );
2336 -
 2336+
23372337 if ( $res !== false ) {
23382338 foreach ( $res as $row ) {
23392339 $result[] = Title::makeTitle( $row->gtl_to_namespace, $row->gtl_to_title, null, $row->gtl_to_prefix );

Status & tagging log