From: Aryeh Gregor Date: Fri, 25 Jul 2008 01:27:51 +0000 (+0000) Subject: Move some member variable initialization to the declarations and out of constructors... X-Git-Tag: 1.31.0-rc.0~46382 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=918d0a78c563f1d82ca7e8bbdea5610919b4c058;p=lhc%2Fweb%2Fwiklou.git Move some member variable initialization to the declarations and out of constructors. This is better style and less error-prone: OutputPage::$mIsPrintable was first being set to true and then to false in the constructor, and $mAllowUserJs and $mLinkColours are missing defaults entirely. Also, Tim said there's some lazy-loading or shared memory or something if it's done this way, so it might be a performance boost. --- diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 6c4b7483d2..219d1cb733 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -6,20 +6,22 @@ if ( ! defined( 'MEDIAWIKI' ) ) * @todo document */ class OutputPage { - var $mMetatags, $mKeywords; - var $mLinktags, $mPagetitle, $mBodytext, $mDebugtext; - var $mHTMLtitle, $mIsarticle, $mPrintable; - var $mSubtitle, $mRedirect, $mStatusCode; - var $mLastModified, $mETag, $mCategoryLinks; - var $mScripts, $mLinkColours, $mPageLinkTitle; + var $mMetatags = array(), $mKeywords = array(), $mLinktags = array(); + var $mPagetitle = '', $mBodytext = '', $mDebugtext = ''; + var $mHTMLtitle = '', $mIsarticle = true, $mPrintable = false; + var $mSubtitle = '', $mRedirect = '', $mStatusCode; + var $mLastModified = '', $mETag = false; + var $mCategoryLinks = array(), $mLanguageLinks = array(); + var $mScripts = '', $mLinkColours, $mPageLinkTitle = '', $mHeadItems = array(); + var $mTemplateIds = array(); var $mAllowUserJs; - var $mSuppressQuickbar; - var $mOnloadHandler; - var $mDoNothing; - var $mContainsOldMagic, $mContainsNewMagic; - var $mIsArticleRelated; - protected $mParserOptions; // lazy initialised, use parserOptions() + var $mSuppressQuickbar = false; + var $mOnloadHandler = ''; + var $mDoNothing = false; + var $mContainsOldMagic = 0, $mContainsNewMagic = 0; + var $mIsArticleRelated = true; + protected $mParserOptions = null; // lazy initialised, use parserOptions() var $mShowFeedLinks = false; var $mFeedLinksAppendQuery = false; var $mEnableClientCache = true; @@ -29,6 +31,8 @@ class OutputPage { var $mNoGallery = false; var $mPageTitleActionText = ''; var $mParseWarnings = array(); + var $mSquidMaxage = 0; + var $mRevisionId = null; private $mIndexPolicy = 'index'; private $mFollowPolicy = 'follow'; @@ -40,24 +44,6 @@ class OutputPage { function __construct() { global $wgAllowUserJs; $this->mAllowUserJs = $wgAllowUserJs; - $this->mMetatags = $this->mKeywords = $this->mLinktags = array(); - $this->mHTMLtitle = $this->mPagetitle = $this->mBodytext = - $this->mRedirect = $this->mLastModified = $this->mSubtitle = - $this->mDebugtext = $this->mOnloadHandler = $this->mPageLinkTitle = ''; - $this->mIsArticleRelated = $this->mIsarticle = $this->mPrintable = true; - $this->mSuppressQuickbar = $this->mPrintable = false; - $this->mLanguageLinks = array(); - $this->mCategoryLinks = array(); - $this->mDoNothing = false; - $this->mContainsOldMagic = $this->mContainsNewMagic = 0; - $this->mParserOptions = null; - $this->mSquidMaxage = 0; - $this->mScripts = ''; - $this->mHeadItems = array(); - $this->mETag = false; - $this->mRevisionId = null; - $this->mNewSectionLink = false; - $this->mTemplateIds = array(); } public function redirect( $url, $responsecode = '302' ) { diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index a15a71d4ac..35951387dd 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -5,26 +5,26 @@ */ class ParserOutput { - var $mText, # The output text - $mLanguageLinks, # List of the full text of language links, in the order they appear - $mCategories, # Map of category names to sort keys - $mContainsOldMagic, # Boolean variable indicating if the input contained variables like {{CURRENTDAY}} - $mCacheTime, # Time when this object was generated, or -1 for uncacheable. Used in ParserCache. - $mVersion, # Compatibility check - $mTitleText, # title text of the chosen language variant - $mLinks, # 2-D map of NS/DBK to ID for the links in the document. ID=zero for broken. - $mTemplates, # 2-D map of NS/DBK to ID for the template references. ID=zero for broken. - $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 - $mNewSection, # Show a new section link? - $mNoGallery, # No gallery on category page? (__NOGALLERY__) - $mHeadItems, # Items to put in the section - $mOutputHooks, # Hook tags as per $wgParserOutputHooks - $mWarnings, # Warning text to be returned to the user. Wikitext formatted, in the key only - $mSections, # Table of contents - $mProperties; # Name/value pairs to be cached in the DB - private $mIndexPolicy = ''; # 'index' or 'noindex'? Any other value will result in no change. + var $mText, # The output text + $mLanguageLinks, # List of the full text of language links, in the order they appear + $mCategories, # Map of category names to sort keys + $mContainsOldMagic, # Boolean variable indicating if the input contained variables like {{CURRENTDAY}} + $mTitleText, # title text of the chosen language variant + $mCacheTime = '', # Time when this object was generated, or -1 for uncacheable. Used in ParserCache. + $mVersion = Parser::VERSION, # Compatibility check + $mLinks = array(), # 2-D map of NS/DBK to ID for the links in the document. ID=zero for broken. + $mTemplates = array(), # 2-D map of NS/DBK to ID for the template references. ID=zero for broken. + $mTemplateIds = array(), # 2-D map of NS/DBK to rev ID for the template references. ID=zero for broken. + $mImages = array(), # DB keys of the images used, in the array key only + $mExternalLinks = array(), # External link URLs, in the key only + $mNewSection = false, # Show a new section link? + $mNoGallery = false, # No gallery on category page? (__NOGALLERY__) + $mHeadItems = array(), # Items to put in the section + $mOutputHooks = array(), # Hook tags as per $wgParserOutputHooks + $mWarnings = array(), # Warning text to be returned to the user. Wikitext formatted, in the key only + $mSections = array(), # Table of contents + $mProperties = array(); # Name/value pairs to be cached in the DB + private $mIndexPolicy = ''; # 'index' or 'noindex'? Any other value will result in no change. /** * Overridden title for display @@ -38,21 +38,7 @@ class ParserOutput $this->mLanguageLinks = $languageLinks; $this->mCategories = $categoryLinks; $this->mContainsOldMagic = $containsOldMagic; - $this->mCacheTime = ''; - $this->mVersion = Parser::VERSION; $this->mTitleText = $titletext; - $this->mSections = array(); - $this->mLinks = array(); - $this->mTemplates = array(); - $this->mImages = array(); - $this->mExternalLinks = array(); - $this->mNewSection = false; - $this->mNoGallery = false; - $this->mHeadItems = array(); - $this->mTemplateIds = array(); - $this->mOutputHooks = array(); - $this->mWarnings = array(); - $this->mProperties = array(); } function getText() { return $this->mText; }