Fix up DISPLAYTITLE and enable per default:
authorRob Church <robchurch@users.mediawiki.org>
Mon, 25 Jun 2007 15:51:09 +0000 (15:51 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Mon, 25 Jun 2007 15:51:09 +0000 (15:51 +0000)
* 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.]

RELEASE-NOTES
includes/CoreParserFunctions.php
includes/DefaultSettings.php
includes/OutputPage.php
includes/Parser.php
includes/ParserOutput.php

index 08d50df..6da070f 100644 (file)
@@ -102,7 +102,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Added option to install to MyISAM
 * (bug 9250) Remove hardcoded minimum image name length of three characters
 * (bug 10338) Enforce signature length limit in Unicode characters instead of bytes
-
+* Fixed DISPLAYTITLE behaviour to reject titles which don't normalise to the
+  same title as the current page, and enabled per default
 
 == Bugfixes since 1.10 ==
 
index 72ceb45..6cf35f9 100644 (file)
@@ -97,15 +97,20 @@ class CoreParserFunctions {
                return $parser->getFunctionLang()->convertPlural( $text, $arg0, $arg1, $arg2, $arg3, $arg4 );
        }
 
-       static function displaytitle( $parser, $param = '' ) {
-               $parserOptions = new ParserOptions;
-               $local_parser = clone $parser;
-               $t2 = $local_parser->parse ( $param, $parser->mTitle, $parserOptions, false );
-               $parser->mOutput->mHTMLtitle = $t2->GetText();
-
-               # Add subtitle
-               $t = $parser->mTitle->getPrefixedText();
-               $parser->mOutput->mSubtitle .= wfMsg('displaytitle', $t);
+       /**
+        * Override the title of the page when viewed,
+        * provided we've been given a title which
+        * will normalise to the canonical title
+        *
+        * @param Parser $parser Parent parser
+        * @param string $text Desired title text
+        * @return string
+        */
+       static function displaytitle( $parser, $text = '' ) {
+               $text = trim( $text );
+               $title = Title::newFromText( $text );
+               if( $title instanceof Title && $title->equals( $parser->mTitle ) )
+                       $parser->mOutput->setDisplayTitle( $text );
                return '';
        }
 
index 5a81b71..67ca01c 100644 (file)
@@ -2539,7 +2539,7 @@ $wgAjaxWatch = true;
 /**
  * Allow DISPLAYTITLE to change title display
  */
-$wgAllowDisplayTitle = false ;
+$wgAllowDisplayTitle = true;
 
 /**
  * Array of usernames which may not be registered or logged in from
index 75e4ef9..ed5674f 100644 (file)
@@ -381,17 +381,15 @@ class OutputPage {
                if ( $parserOutput->getCacheTime() == -1 ) {
                        $this->enableClientCache( false );
                }
-               if ( $parserOutput->mHTMLtitle != "" ) {
-                       $this->mPagetitle = $parserOutput->mHTMLtitle ;
-               }
-               if ( $parserOutput->mSubtitle != '' ) {
-                       $this->mSubtitle .= $parserOutput->mSubtitle ;
-               }
                $this->mNoGallery = $parserOutput->getNoGallery();
                $this->mHeadItems = array_merge( $this->mHeadItems, (array)$parserOutput->mHeadItems );
                // Versioning...
                $this->mTemplateIds += (array)$parserOutput->mTemplateIds;
                
+               # Display title
+               if( ( $dt = $parserOutput->getDisplayTitle() ) !== false )
+                       $this->setPageTitle( $dt );
+               
                wfRunHooks( 'OutputPageParserOutput', array( &$this, $parserOutput ) );
        }
 
index 50f9ac1..e4418cd 100644 (file)
@@ -12,7 +12,7 @@
  * changes in an incompatible way, so the parser cache
  * can automatically discard old data.
  */
-define( 'MW_PARSER_VERSION', '1.6.1' );
+define( 'MW_PARSER_VERSION', '1.6.2' );
 
 define( 'RLH_FOR_UPDATE', 1 );
 
index ba9db73..fed4538 100644 (file)
@@ -17,11 +17,14 @@ class ParserOutput
                $mTemplateIds,      # 2-D map of NS/DBK to rev ID for the template references. ID=zero for broken.
                $mImages,           # DB keys of the images used, in the array key only
                $mExternalLinks,    # External link URLs, in the key only
-               $mHTMLtitle,        # Display HTML title
-               $mSubtitle,         # Additional subtitle
                $mNewSection,       # Show a new section link?
                $mNoGallery,        # No gallery on category page? (__NOGALLERY__)
                $mHeadItems;        # Items to put in the <head> section
+       
+       /**
+        * Overridden title for display
+        */
+       private $displayTitle = false;
 
        function ParserOutput( $text = '', $languageLinks = array(), $categoryLinks = array(),
                $containsOldMagic = false, $titletext = '' )
@@ -37,8 +40,6 @@ class ParserOutput
                $this->mTemplates = array();
                $this->mImages = array();
                $this->mExternalLinks = array();
-               $this->mHTMLtitle = "" ;
-               $this->mSubtitle = "" ;
                $this->mNewSection = false;
                $this->mNoGallery = false;
                $this->mHeadItems = array();
@@ -65,7 +66,6 @@ class ParserOutput
        function setContainsOldMagic( $com ) { return wfSetVar( $this->mContainsOldMagic, $com ); }
        function setCacheTime( $t )          { return wfSetVar( $this->mCacheTime, $t ); }
        function setTitleText( $t )          { return wfSetVar($this->mTitleText, $t); }
-       function setSubtitle( $st )          { return wfSetVar( $this->mSubtitle, $st ); }
 
        function addCategory( $c, $sort )    { $this->mCategories[$c] = $sort; }
        function addLanguageLink( $t )       { $this->mLanguageLinks[] = $t; }
@@ -137,6 +137,27 @@ class ParserOutput
                        $this->mHeadItems[] = $section;
                }
        }
+       
+       /**
+        * Override the title to be used for display
+        * -- this is assumed to have been validated
+        * (check equal normalisation, etc.)
+        *
+        * @param string $text Desired title text
+        */
+       public function setDisplayTitle( $text ) {
+               $this->displayTitle = $text;
+       }
+       
+       /**
+        * Get the title to be used for display
+        *
+        * @return string
+        */
+       public function getDisplayTitle() {
+               return $this->displayTitle;
+       }
+       
 }
 
 ?>