r58275 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58274‎ | r58275 | r58276 >
Date:19:09, 28 October 2009
Author:philip
Status:resolved (Comments)
Tags:
Comment:
(bug 20884) Try to fix the magic word __NOTC__ which use to prevent title-conversion. Now it should work AGAIN.
Modified paths:
  • /trunk/phase3/languages/LanguageConverter.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/LanguageConverter.php
@@ -22,7 +22,6 @@
2323 var $mTablesLoaded = false;
2424 var $mTables;
2525 var $mNamespaceTables;
26 - var $mTitleDisplay='';
2726 var $mDoTitleConvert=true, $mDoContentConvert=true;
2827 var $mManualLevel; // 'bidirectional' 'unidirectional' 'disable' for each variants
2928 var $mTitleFromFlag = false;
@@ -32,6 +31,8 @@
3332 var $mFlags;
3433 var $mDescCodeSep = ':',$mDescVarSep = ';';
3534 var $mUcfirst = false;
 35+ var $mTitleOriginal = '';
 36+ var $mTitleDisplay = '';
3637
3738 const CACHE_VERSION_KEY = 'VERSION 6';
3839
@@ -439,8 +440,9 @@
440441
441442 $text = $this->convert( $text );
442443
443 - if ( $this->mTitleFromFlag )
444 - $parser->mOutput->setTitleText( $this->mTitleDisplay );
 444+ $this->convertTitle();
 445+ $parser->mOutput->setTitleText( $this->mTitleDisplay );
 446+
445447 return $text;
446448 }
447449
@@ -461,35 +463,37 @@
462464 }
463465
464466 /**
 467+ * Pre convert title. Store the original title $this->mTitleOrginal;
 468+ * store the default converted title to $this->mTitleDisplay.
 469+ * @private
 470+ */
 471+ function preConvertTitle( $text, $variant ){
 472+ $this->mTitleOriginal = $text;
 473+
 474+ $text = $this->convertNamespace( $text, $variant );
 475+ $this->mTitleDisplay = $this->convert( $text );
 476+ }
 477+
 478+ /**
465479 * convert title
466480 * @private
467481 */
468 - function convertTitle( $text, $variant ){
469 - global $wgDisableTitleConversion, $wgUser;
470 -
471 - // check for global param and __NOTC__ tag
472 - if( $wgDisableTitleConversion || !$this->mDoTitleConvert || $wgUser->getOption('noconvertlink') == 1 ) {
473 - $this->mTitleDisplay = $text;
474 - return $text;
475 - }
476 -
477 - // use the title from the T flag if any
478 - if( $this->mTitleFromFlag ){
479 - $this->mTitleFromFlag = false;
480 - return $this->mTitleDisplay;
481 - }
482 -
483 - global $wgRequest;
 482+ function convertTitle(){
 483+ global $wgDisableTitleConversion, $wgUser, $wgRequest;
484484 $isredir = $wgRequest->getText( 'redirect', 'yes' );
485485 $action = $wgRequest->getText( 'action' );
486486 $linkconvert = $wgRequest->getText( 'linkconvert', 'yes' );
487 - if ( $isredir == 'no' || $action == 'edit' || $action == 'submit' || $linkconvert == 'no' ) {
488 - return $text;
489 - } else {
490 - $text = $this->convertNamespace( $text, $variant );
491 - $this->mTitleDisplay = $this->convert( $text );
492 - return $this->mTitleDisplay;
 487+
 488+ // check for the global variable, __NOTC__ magic word, and user setting
 489+ if( $wgDisableTitleConversion || !$this->mDoTitleConvert ||
 490+ $wgUser->getOption('noconvertlink') == 1 ) {
 491+ $this->mTitleDisplay = $this->mTitleOriginal;
493492 }
 493+
 494+ // check for GET params
 495+ elseif ( $isredir == 'no' || $action == 'edit' || $linkconvert == 'no' ) {
 496+ $this->mTitleDisplay = $this->mTitleOriginal;
 497+ }
494498 }
495499
496500 /**
@@ -526,7 +530,10 @@
527531 $plang = $this->getPreferredVariant();
528532
529533 // for title convertion
530 - if ( $isTitle ) return $this->convertTitle( $text, $plang );
 534+ if ( $isTitle ) {
 535+ $this->preConvertTitle( $text, $plang );
 536+ return $text;
 537+ }
531538
532539 $tarray = StringUtils::explode( $this->mMarkup['end'], $text );
533540 $text = '';

Follow-up revisions

RevisionCommit summaryAuthorDate
r60765follow-up r60763 and r58275. Parser tests now pass.mah04:53, 7 January 2010
r60767follow-up r60763 and r58275. Parser tests now pass.mah05:00, 7 January 2010

Comments

#Comment by Tim Starling (talk | contribs)   06:53, 31 December 2009

It's still broken. It relies on preConvertTitle() being called before parserConvert(), in order to inform the converter of what the title is. But preConvertTitle() is only called on page view. On page save, preConvertTitle() is never called, so an entry is saved into the parser cache with mTitleText=. This causes subsequent parser cache hits to be shown with no title conversion.

I'm thinking I might have to do some work on this myself.

#Comment by MarkAHershberger (talk | contribs)   04:20, 7 January 2010

This should be fixed in r60763

Status & tagging log