r65393 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65392‎ | r65393 | r65394 >
Date:14:51, 21 April 2010
Author:tstarling
Status:deferred
Tags:
Comment:
MFT r64876 and followups r64892, r64918, 64934: fix various language converter-related title issues.
Modified paths:
  • /branches/REL1_16/phase3 (modified) (history)
  • /branches/REL1_16/phase3/RELEASE-NOTES (modified) (history)
  • /branches/REL1_16/phase3/includes (modified) (history)
  • /branches/REL1_16/phase3/includes/Article.php (modified) (history)
  • /branches/REL1_16/phase3/includes/OutputPage.php (modified) (history)
  • /branches/REL1_16/phase3/includes/parser/Parser.php (modified) (history)
  • /branches/REL1_16/phase3/languages/Language.php (modified) (history)
  • /branches/REL1_16/phase3/languages/LanguageConverter.php (modified) (history)

Diff [purge]

Index: branches/REL1_16/phase3/includes/Article.php
@@ -799,15 +799,6 @@
800800 wfIncrStats( 'pcache_miss_stub' );
801801 }
802802
803 - # For the main page, overwrite the <title> element with the con-
804 - # tents of 'pagetitle-view-mainpage' instead of the default (if
805 - # that's not empty).
806 - if ( $this->mTitle->equals( Title::newMainPage() )
807 - && ( $m = wfMsgForContent( 'pagetitle-view-mainpage' ) ) !== '' )
808 - {
809 - $wgOut->setHTMLTitle( $m );
810 - }
811 -
812803 $wasRedirected = $this->showRedirectedFromHeader();
813804 $this->showNamespaceHeader();
814805
@@ -815,6 +806,7 @@
816807 # Keep going until $outputDone is set, or we run out of things to do.
817808 $pass = 0;
818809 $outputDone = false;
 810+ $this->mParserOutput = false;
819811 while ( !$outputDone && ++$pass ) {
820812 switch( $pass ) {
821813 case 1:
@@ -923,6 +915,23 @@
924916 }
925917 }
926918
 919+ # Adjust the title if it was set by displaytitle, -{T|}- or language conversion
 920+ if ( $this->mParserOutput ) {
 921+ $titleText = $this->mParserOutput->getTitleText();
 922+ if ( strval( $titleText ) !== '' ) {
 923+ $wgOut->setPageTitle( $titleText );
 924+ }
 925+ }
 926+
 927+ # For the main page, overwrite the <title> element with the con-
 928+ # tents of 'pagetitle-view-mainpage' instead of the default (if
 929+ # that's not empty).
 930+ if ( $this->mTitle->equals( Title::newMainPage() )
 931+ && ( $m = wfMsgForContent( 'pagetitle-view-mainpage' ) ) !== '' )
 932+ {
 933+ $wgOut->setHTMLTitle( $m );
 934+ }
 935+
927936 # Now that we've filled $this->mParserOutput, we know whether
928937 # there are any __NOINDEX__ tags on the page
929938 $policy = $this->getRobotPolicy( 'view' );
Property changes on: branches/REL1_16/phase3/includes/Article.php
___________________________________________________________________
Added: svn:mergeinfo
930939 Merged /branches/sqlite/includes/Article.php:r58211-58321
931940 Merged /trunk/phase3/includes/Article.php:r63549,63764,63897-63901,64918,64934
932941 Merged /branches/wmf-deployment/includes/Article.php:r53381
933942 Merged /branches/REL1_15/phase3/includes/Article.php:r51646
Index: branches/REL1_16/phase3/includes/parser/Parser.php
@@ -305,7 +305,7 @@
306306 * to internalParse() which does all the real work.
307307 */
308308
309 - global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang, $wgDisableLangConversion, $wgUser, $wgRequest, $wgDisableTitleConversion;
 309+ global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang, $wgDisableLangConversion, $wgDisableTitleConversion;
310310 $fname = __METHOD__.'-' . wfGetCaller();
311311 wfProfileIn( __METHOD__ );
312312 wfProfileIn( $fname );
@@ -379,16 +379,16 @@
380380 */
381381 if ( !( $wgDisableLangConversion
382382 || $wgDisableTitleConversion
383 - || $wgRequest->getText( 'redirect', 'yes' ) == 'no'
384 - || $wgRequest->getText( 'linkconvert', 'yes' ) == 'no'
385383 || isset( $this->mDoubleUnderscores['nocontentconvert'] )
386384 || isset( $this->mDoubleUnderscores['notitleconvert'] )
387 - || $wgUser->getOption( 'noconvertlink' ) == 1 ) ) {
 385+ || $this->mOutput->getDisplayTitle() !== false ) )
 386+ {
388387 $convruletitle = $wgContLang->getConvRuleTitle();
389388 if ( $convruletitle ) {
390389 $this->mOutput->setTitleText( $convruletitle );
391390 } else {
392 - $this->mOutput->setTitleText( $wgContLang->convert( $title->getPrefixedText(), true ) );
 391+ $titleText = $wgContLang->convertTitle( $title );
 392+ $this->mOutput->setTitleText( $titleText );
393393 }
394394 }
395395
Index: branches/REL1_16/phase3/includes/OutputPage.php
@@ -477,7 +477,7 @@
478478 }
479479
480480 # change "<i>foo&amp;bar</i>" to "foo&bar"
481 - $this->setHTMLTitle( wfMsg( 'pagetitle', Sanitizer::stripAllTags( $nameWithTags ) ), true );
 481+ $this->setHTMLTitle( wfMsg( 'pagetitle', Sanitizer::stripAllTags( $nameWithTags ) ) );
482482 }
483483
484484 /**
Property changes on: branches/REL1_16/phase3/includes/OutputPage.php
___________________________________________________________________
Modified: svn:mergeinfo
485485 Merged /trunk/phase3/includes/OutputPage.php:r64892,64918
Property changes on: branches/REL1_16/phase3/includes
___________________________________________________________________
Modified: svn:mergeinfo
486486 Merged /trunk/phase3/includes:r64876
Index: branches/REL1_16/phase3/languages/LanguageConverter.php
@@ -520,24 +520,6 @@
521521 }
522522
523523 /**
524 - * Convert namespace.
525 - * @param $title String: the title included namespace
526 - * @return Array of string
527 - * @private
528 - */
529 - function convertNamespace( $title, $variant ) {
530 - $splittitle = explode( ':', $title, 2 );
531 - if ( count( $splittitle ) < 2 ) {
532 - return $title;
533 - }
534 - if ( isset( $this->mNamespaceTables[$variant][$splittitle[0]] ) ) {
535 - $splittitle[0] = $this->mNamespaceTables[$variant][$splittitle[0]];
536 - }
537 - $ret = implode( ':', $splittitle );
538 - return $ret;
539 - }
540 -
541 - /**
542524 * Convert text to different variants of a language. The automatic
543525 * conversion is done in autoConvert(). Here we parse the text
544526 * marked with -{}-, which specifies special conversions of the
@@ -551,19 +533,34 @@
552534 * @param $text String: text to be converted
553535 * @return String: converted text
554536 */
555 - public function convert( $text, $istitle = false ) {
 537+ public function convert( $text ) {
556538 global $wgDisableLangConversion;
557539 if ( $wgDisableLangConversion ) return $text;
558540
559541 $variant = $this->getPreferredVariant();
560542
561 - if( $istitle ) {
562 - $text = $this->convertNamespace( $text, $variant );
563 - }
564 -
565543 return $this->recursiveConvertTopLevel( $text, $variant );
566544 }
567545
 546+ /**
 547+ * Convert a Title object to a readable string in the preferred variant
 548+ */
 549+ public function convertTitle( $title ) {
 550+ $variant = $this->getPreferredVariant();
 551+ if ( $title->getNamespace() === NS_MAIN ) {
 552+ $text = '';
 553+ } else {
 554+ $text = $title->getNsText();
 555+ if ( isset( $this->mNamespaceTables[$variant][$text] ) ) {
 556+ $text = $this->mNamespaceTables[$variant][$text];
 557+ }
 558+ $text .= ':';
 559+ }
 560+ $text .= $title->getText();
 561+ $text = $this->autoConvert( $text, $variant );
 562+ return $text;
 563+ }
 564+
568565 protected function recursiveConvertTopLevel( $text, $variant, $depth = 0 ) {
569566 $startPos = 0;
570567 $out = '';
Index: branches/REL1_16/phase3/languages/Language.php
@@ -34,9 +34,10 @@
3535 */
3636 class FakeConverter {
3737 var $mLang;
38 - function FakeConverter($langobj) {$this->mLang = $langobj;}
39 - function autoConvertToAllVariants($text) {return $text;}
40 - function convert($t, $i) {return $t;}
 38+ function FakeConverter( $langobj ) { $this->mLang = $langobj; }
 39+ function autoConvertToAllVariants( $text ) { return $text; }
 40+ function convert( $t ) { return $t; }
 41+ function convertTitle( $t ) { return $t->getPrefixedText(); }
4142 function getVariants() { return array( $this->mLang->getCode() ); }
4243 function getPreferredVariant() { return $this->mLang->getCode(); }
4344 function getConvRuleTitle() { return false; }
@@ -2319,10 +2320,15 @@
23202321 }
23212322
23222323 # convert text to different variants of a language.
2323 - function convert( $text, $isTitle = false) {
2324 - return $this->mConverter->convert($text, $isTitle);
 2324+ function convert( $text ) {
 2325+ return $this->mConverter->convert( $text );
23252326 }
23262327
 2328+ # Convert a Title object to a string in the preferred variant
 2329+ function convertTitle( $title ) {
 2330+ return $this->mConverter->convertTitle( $title );
 2331+ }
 2332+
23272333 # Check if this is a language with variants
23282334 function hasVariants(){
23292335 return sizeof($this->getVariants())>1;
Index: branches/REL1_16/phase3/RELEASE-NOTES
@@ -51,6 +51,8 @@
5252 * Fixed a bug in the Vector skin where personal tools display behind the logo
5353 * (bug 23139) Fixed a bug in edit conflict resolution, where both textboxes
5454 showed the same text.
 55+* (bug 23115, bug 23124) Fixed various problems with <title> and <h1> elements
 56+ in page views and previews when the language converter is enabled.
5557
5658 === Changes since 1.16 beta 1 ===
5759
Property changes on: branches/REL1_16/phase3
___________________________________________________________________
Modified: svn:mergeinfo
5860 Merged /trunk/phase3:r64876

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r64876Proposed cleanup of recent LanguageConverter-related commits:...tstarling13:38, 10 April 2010
r64892Follow up r64876 setHTMLTitle with boolean parameter left.platonides18:29, 10 April 2010
r64918Fix for issue noted on CR r64876: fatal error on CSS/JS subpage displaytstarling23:52, 10 April 2010

Status & tagging log