Only call ParserOptions::getNumberHeadings() when needed for the benefit of cache...
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sun, 6 Mar 2011 21:16:22 +0000 (21:16 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sun, 6 Mar 2011 21:16:22 +0000 (21:16 +0000)
Also fixed a bug in ParserOutput when no option is used; otherwise getUsedOptions() will return false and throw warnings in ParserOptions::optionsHash().

includes/parser/Parser.php
includes/parser/ParserOutput.php

index 5d1535d..fa84d28 100644 (file)
@@ -3685,8 +3685,6 @@ class Parser {
        function formatHeadings( $text, $origText, $isMain=true ) {
                global $wgMaxTocLevel, $wgContLang, $wgHtml5, $wgExperimentalHtmlIds;
 
-               $doNumberHeadings = $this->mOptions->getNumberHeadings();
-
                # Inhibit editsection links if requested in the page
                if ( isset( $this->mDoubleUnderscores['noeditsection'] ) ) {
                        $showEditLink = 0;
@@ -3904,7 +3902,7 @@ class Parser {
                        }
 
                        # Don't number the heading if it is the only one (looks silly)
-                       if ( $doNumberHeadings && count( $matches[3] ) > 1) {
+                       if ( count( $matches[3] ) > 1 && $this->mOptions->getNumberHeadings() ) {
                                # the two are different if the line contains a link
                                $headline = $numbering . ' ' . $headline;
                        }
index d847fc7..401b309 100644 (file)
@@ -123,7 +123,7 @@ class ParserOutput extends CacheTime {
                $mProperties = array(),       # Name/value pairs to be cached in the DB
                $mTOCHTML = '';               # HTML of the TOC
        private $mIndexPolicy = '';           # 'index' or 'noindex'?  Any other value will result in no change.
-       private $mAccessedOptions = null; # List of ParserOptions (stored in the keys)
+       private $mAccessedOptions = array(); # List of ParserOptions (stored in the keys)
 
        const EDITSECTION_REGEX = '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#';