r23393 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23392‎ | r23393 | r23394 >
Date:15:51, 25 June 2007
Author:robchurch
Status:old
Tags:
Comment:
Fix up DISPLAYTITLE and enable per default:
* Clean up the mess in ParserOutput
* Reject (ignore) custom titles which don't normalise to the same as the current page -- THIS IS IMPORTANT OTHERWISE LINKING GOES TO POT (and not the good kind of pot)
[WARNING: Touches parser version. Old caches will be expired. You might wish to undo this and add some temporarily backwards-compatibility for a few days.]
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/CoreParserFunctions.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/Parser.php (modified) (history)
  • /trunk/phase3/includes/ParserOutput.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ParserOutput.php
@@ -17,11 +17,14 @@
1818 $mTemplateIds, # 2-D map of NS/DBK to rev ID for the template references. ID=zero for broken.
1919 $mImages, # DB keys of the images used, in the array key only
2020 $mExternalLinks, # External link URLs, in the key only
21 - $mHTMLtitle, # Display HTML title
22 - $mSubtitle, # Additional subtitle
2321 $mNewSection, # Show a new section link?
2422 $mNoGallery, # No gallery on category page? (__NOGALLERY__)
2523 $mHeadItems; # Items to put in the <head> section
 24+
 25+ /**
 26+ * Overridden title for display
 27+ */
 28+ private $displayTitle = false;
2629
2730 function ParserOutput( $text = '', $languageLinks = array(), $categoryLinks = array(),
2831 $containsOldMagic = false, $titletext = '' )
@@ -37,8 +40,6 @@
3841 $this->mTemplates = array();
3942 $this->mImages = array();
4043 $this->mExternalLinks = array();
41 - $this->mHTMLtitle = "" ;
42 - $this->mSubtitle = "" ;
4344 $this->mNewSection = false;
4445 $this->mNoGallery = false;
4546 $this->mHeadItems = array();
@@ -65,7 +66,6 @@
6667 function setContainsOldMagic( $com ) { return wfSetVar( $this->mContainsOldMagic, $com ); }
6768 function setCacheTime( $t ) { return wfSetVar( $this->mCacheTime, $t ); }
6869 function setTitleText( $t ) { return wfSetVar($this->mTitleText, $t); }
69 - function setSubtitle( $st ) { return wfSetVar( $this->mSubtitle, $st ); }
7070
7171 function addCategory( $c, $sort ) { $this->mCategories[$c] = $sort; }
7272 function addLanguageLink( $t ) { $this->mLanguageLinks[] = $t; }
@@ -137,6 +137,27 @@
138138 $this->mHeadItems[] = $section;
139139 }
140140 }
 141+
 142+ /**
 143+ * Override the title to be used for display
 144+ * -- this is assumed to have been validated
 145+ * (check equal normalisation, etc.)
 146+ *
 147+ * @param string $text Desired title text
 148+ */
 149+ public function setDisplayTitle( $text ) {
 150+ $this->displayTitle = $text;
 151+ }
 152+
 153+ /**
 154+ * Get the title to be used for display
 155+ *
 156+ * @return string
 157+ */
 158+ public function getDisplayTitle() {
 159+ return $this->displayTitle;
 160+ }
 161+
141162 }
142163
143164 ?>
Index: trunk/phase3/includes/Parser.php
@@ -12,7 +12,7 @@
1313 * changes in an incompatible way, so the parser cache
1414 * can automatically discard old data.
1515 */
16 -define( 'MW_PARSER_VERSION', '1.6.1' );
 16+define( 'MW_PARSER_VERSION', '1.6.2' );
1717
1818 define( 'RLH_FOR_UPDATE', 1 );
1919
Index: trunk/phase3/includes/OutputPage.php
@@ -381,17 +381,15 @@
382382 if ( $parserOutput->getCacheTime() == -1 ) {
383383 $this->enableClientCache( false );
384384 }
385 - if ( $parserOutput->mHTMLtitle != "" ) {
386 - $this->mPagetitle = $parserOutput->mHTMLtitle ;
387 - }
388 - if ( $parserOutput->mSubtitle != '' ) {
389 - $this->mSubtitle .= $parserOutput->mSubtitle ;
390 - }
391385 $this->mNoGallery = $parserOutput->getNoGallery();
392386 $this->mHeadItems = array_merge( $this->mHeadItems, (array)$parserOutput->mHeadItems );
393387 // Versioning...
394388 $this->mTemplateIds += (array)$parserOutput->mTemplateIds;
395389
 390+ # Display title
 391+ if( ( $dt = $parserOutput->getDisplayTitle() ) !== false )
 392+ $this->setPageTitle( $dt );
 393+
396394 wfRunHooks( 'OutputPageParserOutput', array( &$this, $parserOutput ) );
397395 }
398396
Index: trunk/phase3/includes/DefaultSettings.php
@@ -2539,7 +2539,7 @@
25402540 /**
25412541 * Allow DISPLAYTITLE to change title display
25422542 */
2543 -$wgAllowDisplayTitle = false ;
 2543+$wgAllowDisplayTitle = true;
25442544
25452545 /**
25462546 * Array of usernames which may not be registered or logged in from
Index: trunk/phase3/includes/CoreParserFunctions.php
@@ -97,15 +97,20 @@
9898 return $parser->getFunctionLang()->convertPlural( $text, $arg0, $arg1, $arg2, $arg3, $arg4 );
9999 }
100100
101 - static function displaytitle( $parser, $param = '' ) {
102 - $parserOptions = new ParserOptions;
103 - $local_parser = clone $parser;
104 - $t2 = $local_parser->parse ( $param, $parser->mTitle, $parserOptions, false );
105 - $parser->mOutput->mHTMLtitle = $t2->GetText();
106 -
107 - # Add subtitle
108 - $t = $parser->mTitle->getPrefixedText();
109 - $parser->mOutput->mSubtitle .= wfMsg('displaytitle', $t);
 101+ /**
 102+ * Override the title of the page when viewed,
 103+ * provided we've been given a title which
 104+ * will normalise to the canonical title
 105+ *
 106+ * @param Parser $parser Parent parser
 107+ * @param string $text Desired title text
 108+ * @return string
 109+ */
 110+ static function displaytitle( $parser, $text = '' ) {
 111+ $text = trim( $text );
 112+ $title = Title::newFromText( $text );
 113+ if( $title instanceof Title && $title->equals( $parser->mTitle ) )
 114+ $parser->mOutput->setDisplayTitle( $text );
110115 return '';
111116 }
112117
Index: trunk/phase3/RELEASE-NOTES
@@ -102,8 +102,9 @@
103103 * Added option to install to MyISAM
104104 * (bug 9250) Remove hardcoded minimum image name length of three characters
105105 * (bug 10338) Enforce signature length limit in Unicode characters instead of bytes
 106+* Fixed DISPLAYTITLE behaviour to reject titles which don't normalise to the
 107+ same title as the current page, and enabled per default
106108
107 -
108109 == Bugfixes since 1.10 ==
109110
110111 * (bug 9712) Use Arabic comma in date/time formats for Arabic and Farsi

Follow-up revisions

RevisionCommit summaryAuthorDate
r23407Merged revisions 23203-23405 via svnmerge from...david23:00, 25 June 2007
r79102Follow up r23393, also remove the getter methodnikerabbit09:54, 28 December 2010

Status & tagging log