Merge "Move ApiQueryRecentChanges::parseRCType to static method on RecentChange"
[lhc/web/wiklou.git] / includes / OutputPage.php
index 9b641c3..0f3612a 100644 (file)
  * @todo document
  */
 class OutputPage extends ContextSource {
-       /// Should be private. Used with addMeta() which adds "<meta>"
-       var $mMetatags = array();
+       /** @var array Should be private. Used with addMeta() which adds "<meta>" */
+       protected $mMetatags = array();
 
-       var $mLinktags = array();
-       var $mCanonicalUrl = false;
+       /** @var array */
+       protected $mLinktags = array();
 
-       /// Additional stylesheets. Looks like this is for extensions. Might be replaced by resource loader.
-       var $mExtStyles = array();
+       /** @var bool */
+       protected $mCanonicalUrl = false;
 
-       /// Should be private - has getter and setter. Contains the HTML title
-       var $mPagetitle = '';
+       /**
+        * @var array Additional stylesheets. Looks like this is for extensions.
+        *   Might be replaced by resource loader.
+        */
+       protected $mExtStyles = array();
+
+       /**
+        * @var string Should be private - has getter and setter. Contains
+        *   the HTML title */
+       public $mPagetitle = '';
 
-       /// Contains all of the "<body>" content. Should be private we got set/get accessors and the append() method.
-       var $mBodytext = '';
+       /**
+        * @var string Contains all of the "<body>" content. Should be private we
+        *   got set/get accessors and the append() method.
+        */
+       public $mBodytext = '';
 
        /**
         * Holds the debug lines that will be output as comments in page source if
@@ -58,43 +69,43 @@ class OutputPage extends ContextSource {
         */
        public $mDebugtext = '';
 
-       /// Should be private. Stores contents of "<title>" tag
-       var $mHTMLtitle = '';
-
-       /// Should be private. Is the displayed content related to the source of the corresponding wiki article.
-       var $mIsarticle = false;
+       /** @var string Stores contents of "<title>" tag */
+       private $mHTMLtitle = '';
 
        /**
-        * Should be private. Has get/set methods properly documented.
-        * Stores "article flag" toggle.
+        * @var bool Is the displayed content related to the source of the
+        *   corresponding wiki article.
         */
-       var $mIsArticleRelated = true;
+       private $mIsarticle = false;
+
+       /** @var bool Stores "article flag" toggle. */
+       private $mIsArticleRelated = true;
 
        /**
-        * Should be private. We have to set isPrintable(). Some pages should
+        * @var bool We have to set isPrintable(). Some pages should
         * never be printed (ex: redirections).
         */
-       var $mPrintable = false;
+       private $mPrintable = false;
 
        /**
-        * Should be private. We have set/get/append methods.
-        *
-        * Contains the page subtitle. Special pages usually have some links here.
-        * Don't confuse with site subtitle added by skins.
+        * @var array Contains the page subtitle. Special pages usually have some
+        *   links here. Don't confuse with site subtitle added by skins.
         */
        private $mSubtitle = array();
 
-       var $mRedirect = '';
-       var $mStatusCode;
+       /** @var string */
+       public $mRedirect = '';
+
+       /** @var int */
+       protected $mStatusCode;
 
        /**
-        * mLastModified and mEtag are used for sending cache control.
-        * The whole caching system should probably be moved into its own class.
+        * @ var string mLastModified and mEtag are used for sending cache control.
+        *   The whole caching system should probably be moved into its own class.
         */
-       var $mLastModified = '';
+       protected $mLastModified = '';
 
        /**
-        * Should be private. No getter but used in sendCacheControl();
         * Contains an HTTP Entity Tags (see RFC 2616 section 3.13) which is used
         * as a unique identifier for the content. It is later used by the client
         * to compare its cached version with the server version. Client sends
@@ -103,70 +114,93 @@ class OutputPage extends ContextSource {
         * To get more information, you will have to look at HTTP/1.1 protocol which
         * is properly described in RFC 2616 : http://tools.ietf.org/html/rfc2616
         */
-       var $mETag = false;
+       private $mETag = false;
+
+       /** @var array */
+       protected $mCategoryLinks = array();
 
-       var $mCategoryLinks = array();
-       var $mCategories = array();
+       /** @var array */
+       protected $mCategories = array();
 
-       /// Should be private. Array of Interwiki Prefixed (non DB key) Titles (e.g. 'fr:Test page')
-       var $mLanguageLinks = array();
+       /** @var array Array of Interwiki Prefixed (non DB key) Titles (e.g. 'fr:Test page') */
+       private $mLanguageLinks = array();
 
        /**
-        * Should be private. Used for JavaScript (pre resource loader)
-        * We should split js / css.
+        * Used for JavaScript (pre resource loader)
+        * @todo We should split JS / CSS.
         * mScripts content is inserted as is in "<head>" by Skin. This might
-        * contains either a link to a stylesheet or inline css.
+        * contain either a link to a stylesheet or inline CSS.
         */
-       var $mScripts = '';
+       private $mScripts = '';
 
-       /**
-        * Inline CSS styles. Use addInlineStyle() sparingly
-        */
-       var $mInlineStyles = '';
+       /** @var string Inline CSS styles. Use addInlineStyle() sparingly */
+       protected $mInlineStyles = '';
 
-       //
-       var $mLinkColours;
+       /** @todo Unused? */
+       private $mLinkColours;
 
        /**
-        * Used by skin template.
+        * @var string Used by skin template.
         * Example: $tpl->set( 'displaytitle', $out->mPageLinkTitle );
         */
-       var $mPageLinkTitle = '';
+       public $mPageLinkTitle = '';
+
+       /** @var array Array of elements in "<head>". Parser might add its own headers! */
+       protected $mHeadItems = array();
+
+       // @todo FIXME: Next 5 variables probably come from the resource loader
+
+       /** @var array */
+       protected $mModules = array();
+
+       /** @var array */
+       protected $mModuleScripts = array();
 
-       /// Array of elements in "<head>". Parser might add its own headers!
-       var $mHeadItems = array();
+       /** @var array */
+       protected $mModuleStyles = array();
 
-       // @todo FIXME: Next variables probably comes from the resource loader
-       var $mModules = array(), $mModuleScripts = array(), $mModuleStyles = array(), $mModuleMessages = array();
-       var $mResourceLoader;
-       var $mJsConfigVars = array();
+       /** @var array */
+       protected $mModuleMessages = array();
 
-       /** @todo FIXME: Is this still used ?*/
-       var $mInlineMsg = array();
+       /** @var ResourceLoader */
+       protected $mResourceLoader;
 
-       var $mTemplateIds = array();
-       var $mImageTimeKeys = array();
+       /** @var array */
+       protected $mJsConfigVars = array();
 
-       var $mRedirectCode = '';
+       /** @var array */
+       protected $mTemplateIds = array();
 
-       var $mFeedLinksAppendQuery = null;
+       /** @var array */
+       protected $mImageTimeKeys = array();
 
-       # What level of 'untrustworthiness' is allowed in CSS/JS modules loaded on this page?
-       # @see ResourceLoaderModule::$origin
-       # ResourceLoaderModule::ORIGIN_ALL is assumed unless overridden;
+       /** @var string */
+       public $mRedirectCode = '';
+
+       protected $mFeedLinksAppendQuery = null;
+
+       /** @var array
+        * What level of 'untrustworthiness' is allowed in CSS/JS modules loaded on this page?
+        * @see ResourceLoaderModule::$origin
+        * ResourceLoaderModule::ORIGIN_ALL is assumed unless overridden;
+        */
        protected $mAllowedModules = array(
                ResourceLoaderModule::TYPE_COMBINED => ResourceLoaderModule::ORIGIN_ALL,
        );
 
+       /** @var bool Whether output is disabled.  If this is true, the 'output' method will do nothing. */
+       protected $mDoNothing = false;
+
+       // Parser related.
+
        /**
-        * Whether output is disabled.  If this is true, the 'output' method will do nothing.
-        *
-        * @var bool $mDoNothing
+        * @var int
+        * @todo Unused?
         */
-       var $mDoNothing = false;
+       private $mContainsOldMagic = 0;
 
-       // Parser related.
-       var $mContainsOldMagic = 0, $mContainsNewMagic = 0;
+       /** @var int */
+       protected $mContainsNewMagic = 0;
 
        /**
         * lazy initialised, use parserOptions()
@@ -175,57 +209,64 @@ class OutputPage extends ContextSource {
        protected $mParserOptions = null;
 
        /**
-        * Handles the atom / rss links.
-        * We probably only support atom in 2011.
-        * Looks like a private variable.
+        * Handles the Atom / RSS links.
+        * We probably only support Atom in 2011.
         * @see $wgAdvertisedFeedTypes
         */
-       var $mFeedLinks = array();
+       private $mFeedLinks = array();
 
        // Gwicke work on squid caching? Roughly from 2003.
-       var $mEnableClientCache = true;
+       protected $mEnableClientCache = true;
 
-       /**
-        * Flag if output should only contain the body of the article.
-        * Should be private.
-        */
-       var $mArticleBodyOnly = false;
+       /** @var bool Flag if output should only contain the body of the article. */
+       private $mArticleBodyOnly = false;
 
-       var $mNewSectionLink = false;
-       var $mHideNewSectionLink = false;
+       /** @var bool */
+       protected $mNewSectionLink = false;
+
+       /** @var bool */
+       protected $mHideNewSectionLink = false;
 
        /**
-        * Comes from the parser. This was probably made to load CSS/JS only
-        * if we had "<gallery>". Used directly in CategoryPage.php
+        * @var bool Comes from the parser. This was probably made to load CSS/JS
+        * only if we had "<gallery>". Used directly in CategoryPage.php.
         * Looks like resource loader can replace this.
         */
-       var $mNoGallery = false;
+       public $mNoGallery = false;
+
+       /** @var string */
+       private $mPageTitleActionText = '';
+
+       /** @var array */
+       private $mParseWarnings = array();
 
-       // should be private.
-       var $mPageTitleActionText = '';
-       var $mParseWarnings = array();
+       /** @var int Cache stuff. Looks like mEnableClientCache */
+       protected $mSquidMaxage = 0;
 
-       // Cache stuff. Looks like mEnableClientCache
-       var $mSquidMaxage = 0;
+       /**
+        * @var bool
+        * @todo Document
+        */
+       protected $mPreventClickjacking = true;
 
-       // @todo document
-       var $mPreventClickjacking = true;
+       /** @var int To include the variable {{REVISIONID}} */
+       private $mRevisionId = null;
 
-       /// should be private. To include the variable {{REVISIONID}}
-       var $mRevisionId = null;
+       /** @var string */
        private $mRevisionTimestamp = null;
 
-       var $mFileVersion = null;
+       /** @var array */
+       protected $mFileVersion = null;
 
        /**
-        * An array of stylesheet filenames (relative from skins path), with options
-        * for CSS media, IE conditions, and RTL/LTR direction.
+        * @var array An array of stylesheet filenames (relative from skins path),
+        * with options for CSS media, IE conditions, and RTL/LTR direction.
         * For internal use; add settings in the skin via $this->addStyle()
         *
         * Style again! This seems like a code duplication since we already have
-        * mStyles. This is what makes OpenSource amazing.
+        * mStyles. This is what makes Open Source amazing.
         */
-       var $styles = array();
+       protected $styles = array();
 
        /**
         * Whether jQuery is already handled.
@@ -295,7 +336,7 @@ class OutputPage extends ContextSource {
        /**
         * Get the URL to redirect to, or an empty string if not redirect URL set
         *
-        * @return String
+        * @return string
         */
        public function getRedirect() {
                return $this->mRedirect;
@@ -304,7 +345,7 @@ class OutputPage extends ContextSource {
        /**
         * Set the HTTP status code to send with the output.
         *
-        * @param $statusCode Integer
+        * @param int $statusCode
         */
        public function setStatusCode( $statusCode ) {
                $this->mStatusCode = $statusCode;
@@ -355,7 +396,7 @@ class OutputPage extends ContextSource {
        /**
         * Get the value of the "rel" attribute for metadata links
         *
-        * @return String
+        * @return string
         */
        public function getMetadataAttribute() {
                # note: buggy CC software only reads first "meta" link
@@ -392,7 +433,7 @@ class OutputPage extends ContextSource {
        /**
         * Get all styles added by extensions
         *
-        * @return Array
+        * @return array
         */
        function getExtStyle() {
                return $this->mExtStyles;
@@ -431,7 +472,7 @@ class OutputPage extends ContextSource {
        /**
         * Get all registered JS and CSS tags for the header.
         *
-        * @return String
+        * @return string
         */
        function getScript() {
                return $this->mScripts . $this->getHeadItems();
@@ -440,12 +481,14 @@ class OutputPage extends ContextSource {
        /**
         * Filter an array of modules to remove insufficiently trustworthy members, and modules
         * which are no longer registered (eg a page is cached before an extension is disabled)
-        * @param $modules Array
-        * @param string $position if not null, only return modules with this position
-        * @param $type string
-        * @return Array
+        * @param array $modules
+        * @param string|null $position if not null, only return modules with this position
+        * @param string $type
+        * @return array
         */
-       protected function filterModules( $modules, $position = null, $type = ResourceLoaderModule::TYPE_COMBINED ) {
+       protected function filterModules( $modules, $position = null,
+               $type = ResourceLoaderModule::TYPE_COMBINED
+       ) {
                $resourceLoader = $this->getResourceLoader();
                $filteredModules = array();
                foreach ( $modules as $val ) {
@@ -464,10 +507,10 @@ class OutputPage extends ContextSource {
        /**
         * Get the list of modules to include on this page
         *
-        * @param bool $filter whether to filter out insufficiently trustworthy modules
-        * @param string $position if not null, only return modules with this position
-        * @param $param string
-        * @return Array of module names
+        * @param bool $filter Whether to filter out insufficiently trustworthy modules
+        * @param string|null $position If not null, only return modules with this position
+        * @param string $param
+        * @return array Array of module names
         */
        public function getModules( $filter = false, $position = null, $param = 'mModules' ) {
                $modules = array_values( array_unique( $this->$param ) );
@@ -490,10 +533,10 @@ class OutputPage extends ContextSource {
        /**
         * Get the list of module JS to include on this page
         *
-        * @param $filter
-        * @param $position
+        * @param bool $filter
+        * @param string|null $position
         *
-        * @return array of module names
+        * @return array Array of module names
         */
        public function getModuleScripts( $filter = false, $position = null ) {
                return $this->getModules( $filter, $position, 'mModuleScripts' );
@@ -513,10 +556,10 @@ class OutputPage extends ContextSource {
        /**
         * Get the list of module CSS to include on this page
         *
-        * @param $filter
-        * @param $position
+        * @param bool $filter
+        * @param string|null $position
         *
-        * @return Array of module names
+        * @return array Array of module names
         */
        public function getModuleStyles( $filter = false, $position = null ) {
                return $this->getModules( $filter, $position, 'mModuleStyles' );
@@ -538,10 +581,10 @@ class OutputPage extends ContextSource {
        /**
         * Get the list of module messages to include on this page
         *
-        * @param $filter
-        * @param $position
+        * @param bool $filter
+        * @param string|null $position
         *
-        * @return Array of module names
+        * @return array Array of module names
         */
        public function getModuleMessages( $filter = false, $position = null ) {
                return $this->getModules( $filter, $position, 'mModuleMessages' );
@@ -568,7 +611,7 @@ class OutputPage extends ContextSource {
        /**
         * Sets ResourceLoader target for load.php links. If null, will be omitted
         *
-        * @param $target string|null
+        * @param string|null $target
         */
        public function setTarget( $target ) {
                $this->mTarget = $target;
@@ -577,7 +620,7 @@ class OutputPage extends ContextSource {
        /**
         * Get an array of head items
         *
-        * @return Array
+        * @return array
         */
        function getHeadItemsArray() {
                return $this->mHeadItems;
@@ -586,7 +629,7 @@ class OutputPage extends ContextSource {
        /**
         * Get all header items in a string
         *
-        * @return String
+        * @return string
         */
        function getHeadItems() {
                $s = '';
@@ -609,8 +652,8 @@ class OutputPage extends ContextSource {
        /**
         * Check if the header item $name is already set
         *
-        * @param string $name item name
-        * @return Boolean
+        * @param string $name Item name
+        * @return bool
         */
        public function hasHeadItem( $name ) {
                return isset( $this->mHeadItems[$name] );
@@ -639,7 +682,7 @@ class OutputPage extends ContextSource {
        /**
         * Return whether the output will contain only the body of the article
         *
-        * @return Boolean
+        * @return bool
         */
        public function getArticleBodyOnly() {
                return $this->mArticleBodyOnly;
@@ -724,7 +767,8 @@ class OutputPage extends ContextSource {
                $clientHeaderTime = strtotime( $clientHeader );
                wfRestoreWarnings();
                if ( !$clientHeaderTime ) {
-                       wfDebug( __METHOD__ . ": unable to parse the client's If-Modified-Since header: $clientHeader\n" );
+                       wfDebug( __METHOD__
+                               . ": unable to parse the client's If-Modified-Since header: $clientHeader\n" );
                        return false;
                }
                $clientHeaderTime = wfTimestamp( TS_MW, $clientHeaderTime );
@@ -833,7 +877,7 @@ class OutputPage extends ContextSource {
        /**
         * Get the value of the "action text"
         *
-        * @return String
+        * @return string
         */
        public function getPageTitleActionText() {
                if ( isset( $this->mPageTitleActionText ) ) {
@@ -846,7 +890,7 @@ class OutputPage extends ContextSource {
         * "HTML title" means the contents of "<title>".
         * It is stored as plain, unescaped text and will be run through htmlspecialchars in the skin file.
         *
-        * @param $name string
+        * @param string $name
         */
        public function setHTMLTitle( $name ) {
                if ( $name instanceof Message ) {
@@ -859,7 +903,7 @@ class OutputPage extends ContextSource {
        /**
         * Return the "HTML title", i.e. the content of the "<title>" tag.
         *
-        * @return String
+        * @return string
         */
        public function getHTMLTitle() {
                return $this->mHTMLtitle;
@@ -868,19 +912,21 @@ class OutputPage extends ContextSource {
        /**
         * Set $mRedirectedFrom, the Title of the page which redirected us to the current page.
         *
-        * @param $t Title
+        * @param Title $t
         */
        public function setRedirectedFrom( $t ) {
                $this->mRedirectedFrom = $t;
        }
 
        /**
-        * "Page title" means the contents of \<h1\>. It is stored as a valid HTML fragment.
-        * This function allows good tags like \<sup\> in the \<h1\> tag, but not bad tags like \<script\>.
-        * This function automatically sets \<title\> to the same content as \<h1\> but with all tags removed.
-        * Bad tags that were escaped in \<h1\> will still be escaped in \<title\>, and good tags like \<i\> will be dropped entirely.
+        * "Page title" means the contents of \<h1\>. It is stored as a valid HTML
+        * fragment. This function allows good tags like \<sup\> in the \<h1\> tag,
+        * but not bad tags like \<script\>. This function automatically sets
+        * \<title\> to the same content as \<h1\> but with all tags removed. Bad
+        * tags that were escaped in \<h1\> will still be escaped in \<title\>, and
+        * good tags like \<i\> will be dropped entirely.
         *
-        * @param $name string|Message
+        * @param string|Message $name
         */
        public function setPageTitle( $name ) {
                if ( $name instanceof Message ) {
@@ -902,7 +948,7 @@ class OutputPage extends ContextSource {
        /**
         * Return the "page title", i.e. the content of the \<h1\> tag.
         *
-        * @return String
+        * @return string
         */
        public function getPageTitle() {
                return $this->mPagetitle;
@@ -911,7 +957,7 @@ class OutputPage extends ContextSource {
        /**
         * Set the Title object to use
         *
-        * @param $t Title object
+        * @param Title $t
         */
        public function setTitle( Title $t ) {
                $this->getContext()->setTitle( $t );
@@ -930,7 +976,7 @@ class OutputPage extends ContextSource {
        /**
         * Add $str to the subtitle
         *
-        * @deprecated in 1.19; use addSubtitle() instead
+        * @deprecated since 1.19; use addSubtitle() instead
         * @param string|Message $str to add to the subtitle
         */
        public function appendSubtitle( $str ) {
@@ -953,14 +999,15 @@ class OutputPage extends ContextSource {
        /**
         * Add a subtitle containing a backlink to a page
         *
-        * @param $title Title to link to
+        * @param Title $title Title to link to
         */
        public function addBacklinkSubtitle( Title $title ) {
                $query = array();
                if ( $title->isRedirect() ) {
                        $query['redirect'] = 'no';
                }
-               $this->addSubtitle( $this->msg( 'backlinksubtitle' )->rawParams( Linker::link( $title, null, array(), $query ) ) );
+               $this->addSubtitle( $this->msg( 'backlinksubtitle' )
+                       ->rawParams( Linker::link( $title, null, array(), $query ) ) );
        }
 
        /**
@@ -973,7 +1020,7 @@ class OutputPage extends ContextSource {
        /**
         * Get the subtitle
         *
-        * @return String
+        * @return string
         */
        public function getSubtitle() {
                return implode( "<br />\n\t\t\t\t", $this->mSubtitle );
@@ -990,7 +1037,7 @@ class OutputPage extends ContextSource {
        /**
         * Return whether the page is "printable"
         *
-        * @return Boolean
+        * @return bool
         */
        public function isPrintable() {
                return $this->mPrintable;
@@ -1006,7 +1053,7 @@ class OutputPage extends ContextSource {
        /**
         * Return whether the output will be completely disabled
         *
-        * @return Boolean
+        * @return bool
         */
        public function isDisabled() {
                return $this->mDoNothing;
@@ -1015,7 +1062,7 @@ class OutputPage extends ContextSource {
        /**
         * Show an "add new section" link?
         *
-        * @return Boolean
+        * @return bool
         */
        public function showNewSectionLink() {
                return $this->mNewSectionLink;
@@ -1024,7 +1071,7 @@ class OutputPage extends ContextSource {
        /**
         * Forcibly hide the new section link?
         *
-        * @return Boolean
+        * @return bool
         */
        public function forceHideNewSectionLink() {
                return $this->mHideNewSectionLink;
@@ -1085,7 +1132,7 @@ class OutputPage extends ContextSource {
 
        /**
         * Should we output feed links for this page?
-        * @return Boolean
+        * @return bool
         */
        public function isSyndicated() {
                return count( $this->mFeedLinks ) > 0;
@@ -1113,7 +1160,7 @@ class OutputPage extends ContextSource {
         * corresponding article on the wiki
         * Setting true will cause the change "article related" toggle to true
         *
-        * @param $v Boolean
+        * @param bool $v
         */
        public function setArticleFlag( $v ) {
                $this->mIsarticle = $v;
@@ -1126,7 +1173,7 @@ class OutputPage extends ContextSource {
         * Return whether the content displayed page is related to the source of
         * the corresponding article on the wiki
         *
-        * @return Boolean
+        * @return bool
         */
        public function isArticle() {
                return $this->mIsarticle;
@@ -1136,7 +1183,7 @@ class OutputPage extends ContextSource {
         * Set whether this page is related an article on the wiki
         * Setting false will cause the change of "article flag" toggle to false
         *
-        * @param $v Boolean
+        * @param bool $v
         */
        public function setArticleRelated( $v ) {
                $this->mIsArticleRelated = $v;
@@ -1148,7 +1195,7 @@ class OutputPage extends ContextSource {
        /**
         * Return whether this page is related an article on the wiki
         *
-        * @return Boolean
+        * @return bool
         */
        public function isArticleRelated() {
                return $this->mIsArticleRelated;
@@ -1177,7 +1224,7 @@ class OutputPage extends ContextSource {
        /**
         * Get the list of language links
         *
-        * @return Array of Interwiki Prefixed (non DB key) Titles (e.g. 'fr:Test page')
+        * @return array Array of Interwiki Prefixed (non DB key) Titles (e.g. 'fr:Test page')
         */
        public function getLanguageLinks() {
                return $this->mLanguageLinks;
@@ -1203,11 +1250,15 @@ class OutputPage extends ContextSource {
                # Fetch existence plus the hiddencat property
                $dbr = wfGetDB( DB_SLAVE );
                $res = $dbr->select( array( 'page', 'page_props' ),
-                       array( 'page_id', 'page_namespace', 'page_title', 'page_len', 'page_is_redirect', 'page_latest', 'pp_value' ),
+                       array( 'page_id', 'page_namespace', 'page_title', 'page_len',
+                               'page_is_redirect', 'page_latest', 'pp_value' ),
                        $lb->constructSet( 'page', $dbr ),
                        __METHOD__,
                        array(),
-                       array( 'page_props' => array( 'LEFT JOIN', array( 'pp_propname' => 'hiddencat', 'pp_page = page_id' ) ) )
+                       array( 'page_props' => array( 'LEFT JOIN', array(
+                               'pp_propname' => 'hiddencat',
+                               'pp_page = page_id'
+                       ) ) )
                );
 
                # Add the results to the link cache
@@ -1227,7 +1278,10 @@ class OutputPage extends ContextSource {
                }
 
                # Add the remaining categories to the skin
-               if ( wfRunHooks( 'OutputPageMakeCategoryLinks', array( &$this, $categories, &$this->mCategoryLinks ) ) ) {
+               if ( wfRunHooks(
+                       'OutputPageMakeCategoryLinks',
+                       array( &$this, $categories, &$this->mCategoryLinks ) )
+               ) {
                        foreach ( $categories as $category => $type ) {
                                $origcategory = $category;
                                $title = Title::makeTitleSafe( NS_CATEGORY, $category );
@@ -1260,7 +1314,7 @@ class OutputPage extends ContextSource {
         * hidden categories) and $link a HTML fragment with a link to the category
         * page
         *
-        * @return Array
+        * @return array
         */
        public function getCategoryLinks() {
                return $this->mCategoryLinks;
@@ -1269,7 +1323,7 @@ class OutputPage extends ContextSource {
        /**
         * Get the list of category names this page belongs to
         *
-        * @return Array of strings
+        * @return array Array of strings
         */
        public function getCategories() {
                return $this->mCategories;
@@ -1290,18 +1344,19 @@ class OutputPage extends ContextSource {
         * Return whether user JavaScript is allowed for this page
         * @deprecated since 1.18 Load modules with ResourceLoader, and origin and
         *     trustworthiness is identified and enforced automagically.
-        * @return Boolean
+        * @return bool
         */
        public function isUserJsAllowed() {
                wfDeprecated( __METHOD__, '1.18' );
-               return $this->getAllowedModules( ResourceLoaderModule::TYPE_SCRIPTS ) >= ResourceLoaderModule::ORIGIN_USER_INDIVIDUAL;
+               return $this->getAllowedModules( ResourceLoaderModule::TYPE_SCRIPTS ) >=
+                       ResourceLoaderModule::ORIGIN_USER_INDIVIDUAL;
        }
 
        /**
         * Show what level of JavaScript / CSS untrustworthiness is allowed on this page
         * @see ResourceLoaderModule::$origin
         * @param string $type ResourceLoaderModule TYPE_ constant
-        * @return Int ResourceLoaderModule ORIGIN_ class constant
+        * @return int ResourceLoaderModule ORIGIN_ class constant
         */
        public function getAllowedModules( $type ) {
                if ( $type == ResourceLoaderModule::TYPE_COMBINED ) {
@@ -1315,8 +1370,8 @@ class OutputPage extends ContextSource {
 
        /**
         * Set the highest level of CSS/JS untrustworthiness allowed
-        * @param $type String ResourceLoaderModule TYPE_ constant
-        * @param $level Int ResourceLoaderModule class constant
+        * @param string $type ResourceLoaderModule TYPE_ constant
+        * @param int $level ResourceLoaderModule class constant
         */
        public function setAllowedModules( $type, $level ) {
                $this->mAllowedModules[$type] = $level;
@@ -1324,8 +1379,8 @@ class OutputPage extends ContextSource {
 
        /**
         * As for setAllowedModules(), but don't inadvertently make the page more accessible
-        * @param $type String
-        * @param $level Int ResourceLoaderModule class constant
+        * @param string $type
+        * @param int $level ResourceLoaderModule class constant
         */
        public function reduceAllowedModules( $type, $level ) {
                $this->mAllowedModules[$type] = min( $this->getAllowedModules( $type ), $level );
@@ -1354,9 +1409,9 @@ class OutputPage extends ContextSource {
         *
         * @since 1.19
         *
-        * @param $element string
-        * @param $attribs array
-        * @param $contents string
+        * @param string $element
+        * @param array $attribs
+        * @param string $contents
         */
        public function addElement( $element, $attribs = array(), $contents = '' ) {
                $this->addHTML( Html::element( $element, $attribs, $contents ) );
@@ -1381,9 +1436,9 @@ class OutputPage extends ContextSource {
        /**
         * Get/set the ParserOptions object to use for wikitext parsing
         *
-        * @param $options ParserOptions|null either the ParserOption to use or null to only get the
-        *                 current ParserOption object
-        * @return ParserOptions object
+        * @param ParserOptions|null $options Either the ParserOption to use or null to only get the
+        *   current ParserOption object
+        * @return ParserOptions
         */
        public function parserOptions( $options = null ) {
                if ( !$this->mParserOptions ) {
@@ -1408,7 +1463,7 @@ class OutputPage extends ContextSource {
        /**
         * Get the displayed revision ID
         *
-        * @return Integer
+        * @return int
         */
        public function getRevisionId() {
                return $this->mRevisionId;
@@ -1429,7 +1484,7 @@ class OutputPage extends ContextSource {
         * Get the timestamp of displayed revision.
         * This will be null if not filled by setRevisionTimestamp().
         *
-        * @return String or null
+        * @return string|null
         */
        public function getRevisionTimestamp() {
                return $this->mRevisionTimestamp;
@@ -1452,7 +1507,7 @@ class OutputPage extends ContextSource {
        /**
         * Get the displayed file version
         *
-        * @return Array|null ('time' => MW timestamp, 'sha1' => sha1)
+        * @return array|null ('time' => MW timestamp, 'sha1' => sha1)
         */
        public function getFileVersion() {
                return $this->mFileVersion;
@@ -1461,7 +1516,7 @@ class OutputPage extends ContextSource {
        /**
         * Get the templates used on this page
         *
-        * @return Array (namespace => dbKey => revId)
+        * @return array (namespace => dbKey => revId)
         * @since 1.18
         */
        public function getTemplateIds() {
@@ -1471,7 +1526,7 @@ class OutputPage extends ContextSource {
        /**
         * Get the files used on this page
         *
-        * @return Array (dbKey => array('time' => MW timestamp or null, 'sha1' => sha1 or ''))
+        * @return array (dbKey => array('time' => MW timestamp or null, 'sha1' => sha1 or ''))
         * @since 1.18
         */
        public function getFileSearchOptions() {
@@ -1537,7 +1592,9 @@ class OutputPage extends ContextSource {
         * @param bool $interface Whether it is an interface message
         *   (for example disables conversion)
         */
-       public function addWikiTextTitle( $text, Title $title, $linestart, $tidy = false, $interface = false ) {
+       public function addWikiTextTitle( $text, Title $title, $linestart,
+               $tidy = false, $interface = false
+       ) {
                global $wgParser;
 
                wfProfileIn( __METHOD__ );
@@ -1561,7 +1618,7 @@ class OutputPage extends ContextSource {
        /**
         * Add a ParserOutput object, but without Html
         *
-        * @param $parserOutput ParserOutput object
+        * @param ParserOutput $parserOutput
         */
        public function addParserOutputNoText( &$parserOutput ) {
                $this->mLanguageLinks += $parserOutput->getLanguageLinks();
@@ -1613,7 +1670,7 @@ class OutputPage extends ContextSource {
        /**
         * Add a ParserOutput object
         *
-        * @param $parserOutput ParserOutput
+        * @param ParserOutput $parserOutput
         */
        function addParserOutput( &$parserOutput ) {
                $this->addParserOutputNoText( $parserOutput );
@@ -1631,7 +1688,7 @@ class OutputPage extends ContextSource {
        /**
         * Add the output of a QuickTemplate to the output buffer
         *
-        * @param $template QuickTemplate
+        * @param QuickTemplate $template
         */
        public function addTemplate( &$template ) {
                $this->addHTML( $template->getHTML() );
@@ -1640,7 +1697,7 @@ class OutputPage extends ContextSource {
        /**
         * Parse wikitext and return the HTML.
         *
-        * @param String $text
+        * @param string $text
         * @param bool $linestart Is this the start of a line?
         * @param bool $interface Use interface language ($wgLang instead of
         *   $wgContLang) while parsing language sensitive magic words like GRAMMAR and PLURAL.
@@ -1691,13 +1748,7 @@ class OutputPage extends ContextSource {
         */
        public function parseInline( $text, $linestart = true, $interface = false ) {
                $parsed = $this->parse( $text, $linestart, $interface );
-
-               $m = array();
-               if ( preg_match( '/^<p>(.*)\n?<\/p>\n?/sU', $parsed, $m ) ) {
-                       $parsed = $m[1];
-               }
-
-               return $parsed;
+               return Parser::stripOuterParagraph( $parsed );
        }
 
        /**
@@ -1712,7 +1763,7 @@ class OutputPage extends ContextSource {
        /**
         * Use enableClientCache(false) to force it to send nocache headers
         *
-        * @param $state bool
+        * @param bool $state
         *
         * @return bool
         */
@@ -1723,7 +1774,7 @@ class OutputPage extends ContextSource {
        /**
         * Get the list of cookies that will influence on the cache
         *
-        * @return Array
+        * @return array
         */
        function getCacheVaryCookies() {
                global $wgCookiePrefix, $wgCacheVaryCookies;
@@ -1747,7 +1798,7 @@ class OutputPage extends ContextSource {
         * Check if the request has a cache-varying cookie header
         * If it does, it's very important that we don't allow public caching
         *
-        * @return Boolean
+        * @return bool
         */
        function haveCacheVaryCookies() {
                $cookieHeader = $this->getRequest()->getHeader( 'cookie' );
@@ -1770,7 +1821,7 @@ class OutputPage extends ContextSource {
         * Add an HTTP header that will influence on the cache
         *
         * @param string $header header name
-        * @param $option Array|null
+        * @param array|null $option
         * @todo FIXME: Document the $option parameter; it appears to be for
         *        X-Vary-Options but what format is acceptable?
         */
@@ -1791,7 +1842,7 @@ class OutputPage extends ContextSource {
         * Return a Vary: header on which to vary caches. Based on the keys of $mVaryHeader,
         * such as Accept-Encoding or Cookie
         *
-        * @return String
+        * @return string
         */
        public function getVaryHeader() {
                return 'Vary: ' . join( ', ', array_keys( $this->mVaryHeader ) );
@@ -1800,7 +1851,7 @@ class OutputPage extends ContextSource {
        /**
         * Get a complete X-Vary-Options header
         *
-        * @return String
+        * @return string
         */
        public function getXVO() {
                $cvCookies = $this->getCacheVaryCookies();
@@ -1864,7 +1915,7 @@ class OutputPage extends ContextSource {
         * This is the default for special pages. If you display a CSRF-protected
         * form on an ordinary view page, then you need to call this function.
         *
-        * @param $enable bool
+        * @param bool $enable
         */
        public function preventClickjacking( $enable = true ) {
                $this->mPreventClickjacking = $enable;
@@ -1931,7 +1982,8 @@ class OutputPage extends ContextSource {
                                        wfDebug( __METHOD__ . ": proxy caching with ESI; {$this->mLastModified} **\n", 'log' );
                                        # start with a shorter timeout for initial testing
                                        # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
-                                       $response->header( 'Surrogate-Control: max-age=' . $wgSquidMaxage . '+' . $this->mSquidMaxage . ', content="ESI/1.0"' );
+                                       $response->header( 'Surrogate-Control: max-age=' . $wgSquidMaxage
+                                               . '+' . $this->mSquidMaxage . ', content="ESI/1.0"' );
                                        $response->header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
                                } else {
                                        # We'll purge the proxy cache for anons explicitly, but require end user agents
@@ -1941,7 +1993,8 @@ class OutputPage extends ContextSource {
                                        wfDebug( __METHOD__ . ": local proxy caching; {$this->mLastModified} **\n", 'log' );
                                        # start with a shorter timeout for initial testing
                                        # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
-                                       $response->header( 'Cache-Control: s-maxage=' . $this->mSquidMaxage . ', must-revalidate, max-age=0' );
+                                       $response->header( 'Cache-Control: s-maxage=' . $this->mSquidMaxage
+                                               . ', must-revalidate, max-age=0' );
                                }
                        } else {
                                # We do want clients to cache if they can, but they *must* check for updates
@@ -2039,6 +2092,10 @@ class OutputPage extends ContextSource {
                $response->header( "Content-type: $wgMimeType; charset=UTF-8" );
                $response->header( 'Content-language: ' . $wgLanguageCode );
 
+               // Avoid Internet Explorer "compatibility view" in IE 8-10, so that
+               // jQuery etc. can work correctly.
+               $response->header( 'X-UA-Compatible: IE=Edge' );
+
                // Prevent framing, if requested
                $frameOptions = $this->getFrameOptions();
                if ( $frameOptions ) {
@@ -2157,7 +2214,9 @@ class OutputPage extends ContextSource {
 
                if ( $msg instanceof Message ) {
                        if ( $params !== array() ) {
-                               trigger_error( 'Argument ignored: $params. The message parameters argument is discarded when the $msg argument is a Message object instead of a string.', E_USER_NOTICE );
+                               trigger_error( 'Argument ignored: $params. The message parameters argument '
+                                       . 'is discarded when the $msg argument is a Message object instead of '
+                                       . 'a string.', E_USER_NOTICE );
                        }
                        $this->addHTML( $msg->parseAsBlock() );
                } else {
@@ -2265,7 +2324,7 @@ class OutputPage extends ContextSource {
        /**
         * Produce the stock "please login to use the wiki" page
         *
-        * @deprecated in 1.19; throw the exception directly
+        * @deprecated since 1.19; throw the exception directly
         */
        public function loginToUse() {
                throw new PermissionsError( 'read' );
@@ -2325,11 +2384,14 @@ class OutputPage extends ContextSource {
         *
         * @param string $source Source code to show (or null).
         * @param bool $protected Is this a permissions error?
-        * @param array $reasons List of reasons for this error, as returned by Title::getUserPermissionsErrors().
+        * @param array $reasons List of reasons for this error, as returned by
+        *   Title::getUserPermissionsErrors().
         * @param string $action Action that was denied or null if unknown
         * @throws ReadOnlyError
         */
-       public function readOnlyPage( $source = null, $protected = false, $reasons = array(), $action = null ) {
+       public function readOnlyPage( $source = null, $protected = false,
+               $reasons = array(), $action = null
+       ) {
                $this->setRobotPolicy( 'noindex,nofollow' );
                $this->setArticleRelated( false );
 
@@ -2442,10 +2504,10 @@ $templates
        /**
         * Add a "return to" link pointing to a specified title
         *
-        * @param $title Title to link
-        * @param array $query query string parameters
-        * @param string $text text of the link (input is not escaped)
-        * @param $options Options array to pass to Linker
+        * @param Title $title Title to link
+        * @param array $query Query string parameters
+        * @param string $text Text of the link (input is not escaped)
+        * @param array $options Options array to pass to Linker
         */
        public function addReturnTo( $title, $query = array(), $text = null, $options = array() ) {
                $link = $this->msg( 'returnto' )->rawParams(
@@ -2457,9 +2519,9 @@ $templates
         * Add a "return to" link pointing to a specified title,
         * or the title indicated in the request, or else the main page
         *
-        * @param $unused
-        * @param $returnto Title or String to return to
-        * @param string $returntoquery query string for the return to link
+        * @param mixed $unused
+        * @param Title|string $returnto Title or String to return to
+        * @param string $returntoquery Query string for the return to link
         */
        public function returnToMain( $unused = null, $returnto = null, $returntoquery = null ) {
                if ( $returnto == null ) {
@@ -2523,10 +2585,6 @@ $templates
 
                $ret .= Html::element( 'title', null, $this->getHTMLTitle() ) . "\n";
 
-               // Avoid Internet Explorer "compatibility view", so that
-               // jQuery can work correctly.
-               $ret .= Html::element( 'meta', array( 'http-equiv' => 'X-UA-Compatible', 'content' => 'IE=EDGE' ) ) . "\n";
-
                $ret .= (
                        $this->getHeadLinks() .
                        "\n" .
@@ -2556,7 +2614,8 @@ $templates
 
                $bodyClasses[] = $sk->getPageClasses( $this->getTitle() );
                $bodyClasses[] = 'skin-' . Sanitizer::escapeClass( $sk->getSkinName() );
-               $bodyClasses[] = 'action-' . Sanitizer::escapeClass( Action::getActionName( $this->getContext() ) );
+               $bodyClasses[] =
+                       'action-' . Sanitizer::escapeClass( Action::getActionName( $this->getContext() ) );
 
                $bodyAttrs = array();
                // While the implode() is not strictly needed, it's used for backwards compatibility
@@ -2585,15 +2644,19 @@ $templates
        }
 
        /**
-        * TODO: Document
+        * @todo Document
         * @param array|string $modules One or more module names
         * @param string $only ResourceLoaderModule TYPE_ class constant
-        * @param boolean $useESI
-        * @param array $extraQuery with extra query parameters to add to each request. array( param => value )
-        * @param boolean $loadCall If true, output an (asynchronous) mw.loader.load() call rather than a "<script src='...'>" tag
+        * @param bool $useESI
+        * @param array $extraQuery Array with extra query parameters to add to each
+        *   request. array( param => value ).
+        * @param bool $loadCall If true, output an (asynchronous) mw.loader.load()
+        *   call rather than a "<script src='...'>" tag.
         * @return string The html "<script>", "<link>" and "<style>" tags
         */
-       protected function makeResourceLoaderLink( $modules, $only, $useESI = false, array $extraQuery = array(), $loadCall = false ) {
+       protected function makeResourceLoaderLink( $modules, $only, $useESI = false,
+               array $extraQuery = array(), $loadCall = false
+       ) {
                global $wgResourceLoaderUseESI;
 
                $modules = (array)$modules;
@@ -2607,7 +2670,6 @@ $templates
                        return $links;
                }
 
-
                if ( count( $modules ) > 1 ) {
                        // Remove duplicate module requests
                        $modules = array_unique( $modules );
@@ -2837,8 +2899,14 @@ $templates
 
                // Scripts and messages "only" requests marked for top inclusion
                // Messages should go first
-               $links[] = $this->makeResourceLoaderLink( $this->getModuleMessages( true, 'top' ), ResourceLoaderModule::TYPE_MESSAGES );
-               $links[] = $this->makeResourceLoaderLink( $this->getModuleScripts( true, 'top' ), ResourceLoaderModule::TYPE_SCRIPTS );
+               $links[] = $this->makeResourceLoaderLink(
+                       $this->getModuleMessages( true, 'top' ),
+                       ResourceLoaderModule::TYPE_MESSAGES
+               );
+               $links[] = $this->makeResourceLoaderLink(
+                       $this->getModuleScripts( true, 'top' ),
+                       ResourceLoaderModule::TYPE_SCRIPTS
+               );
 
                // Modules requests - let the client calculate dependencies and batch requests as it likes
                // Only load modules that have marked themselves for loading at the top
@@ -2859,12 +2927,14 @@ $templates
        }
 
        /**
-        * JS stuff to put at the 'bottom', which can either be the bottom of the "<body>"
-        * or the bottom of the "<head>" depending on $wgResourceLoaderExperimentalAsyncLoading:
-        * modules marked with position 'bottom', legacy scripts ($this->mScripts),
-        * user preferences, site JS and user JS.
+        * JS stuff to put at the 'bottom', which can either be the bottom of the
+        * "<body>" or the bottom of the "<head>" depending on
+        * $wgResourceLoaderExperimentalAsyncLoading: modules marked with position
+        * 'bottom', legacy scripts ($this->mScripts), user preferences, site JS
+        * and user JS.
         *
-        * @param $inHead boolean If true, this HTML goes into the "<head>", if false it goes into the "<body>"
+        * @param bool $inHead If true, this HTML goes into the "<head>",
+        *   if false it goes into the "<body>".
         * @return string
         */
        function getScriptsForBottomQueue( $inHead ) {
@@ -2903,7 +2973,12 @@ $templates
                );
 
                // Add user JS if enabled
-               if ( $wgAllowUserJs && $this->getUser()->isLoggedIn() && $this->getTitle() && $this->getTitle()->isJsSubpage() && $this->userCanPreview() ) {
+               if ( $wgAllowUserJs
+                       && $this->getUser()->isLoggedIn()
+                       && $this->getTitle()
+                       && $this->getTitle()->isJsSubpage()
+                       && $this->userCanPreview()
+               ) {
                        # XXX: additional security check/prompt?
                        // We're on a preview of a JS subpage
                        // Exclude this page from the user module in case it's in there (bug 26283)
@@ -2911,7 +2986,8 @@ $templates
                                array( 'excludepage' => $this->getTitle()->getPrefixedDBkey() ), $inHead
                        );
                        // Load the previewed JS
-                       $links[] = Html::inlineScript( "\n" . $this->getRequest()->getText( 'wpTextbox1' ) . "\n" ) . "\n";
+                       $links[] = Html::inlineScript( "\n"
+                                       . $this->getRequest()->getText( 'wpTextbox1' ) . "\n" ) . "\n";
 
                        // FIXME: If the user is previewing, say, ./vector.js, his ./common.js will be loaded
                        // asynchronously and may arrive *after* the inline script here. So the previewed code
@@ -2954,7 +3030,7 @@ $templates
        /**
         * Get the javascript config vars to include on this page
         *
-        * @return Array of javascript config vars
+        * @return array Array of javascript config vars
         * @since 1.23
         */
        public function getJsConfigVars() {
@@ -2962,10 +3038,10 @@ $templates
        }
 
        /**
-        * Add one or more variables to be set in mw.config in JavaScript.
+        * Add one or more variables to be set in mw.config in JavaScript
         *
-        * @param $keys {String|Array} Key or array of key/value pairs.
-        * @param $value {Mixed} [optional] Value of the configuration variable.
+        * @param string|array $keys Key or array of key/value pairs
+        * @param mixed $value [optional] Value of the configuration variable
         */
        public function addJsConfigVars( $keys, $value = null ) {
                if ( is_array( $keys ) ) {
@@ -2999,7 +3075,9 @@ $templates
 
                $title = $this->getTitle();
                $ns = $title->getNamespace();
-               $canonicalNamespace = MWNamespace::exists( $ns ) ? MWNamespace::getCanonicalName( $ns ) : $title->getNsText();
+               $canonicalNamespace = MWNamespace::exists( $ns )
+                       ? MWNamespace::getCanonicalName( $ns )
+                       : $title->getNsText();
 
                $sk = $this->getSkin();
                // Get the relevant title so that AJAX features can use the correct page name
@@ -3008,7 +3086,8 @@ $templates
                $relevantUser = $sk->getRelevantUser();
 
                if ( $ns == NS_SPECIAL ) {
-                       list( $canonicalSpecialPageName, /*...*/ ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
+                       list( $canonicalSpecialPageName, /*...*/ ) =
+                               SpecialPageFactory::resolveAlias( $title->getDBkey() );
                } elseif ( $this->canUseWikiPage() ) {
                        $wikiPage = $this->getWikiPage();
                        $curRevisionId = $wikiPage->getLatest();
@@ -3058,6 +3137,7 @@ $templates
                        'wgMonthNamesShort' => $lang->getMonthAbbreviationsArray(),
                        'wgRelevantPageName' => $relevantTitle->getPrefixedDBkey(),
                );
+
                if ( $user->isLoggedIn() ) {
                        $vars['wgUserId'] = $user->getId();
                        $vars['wgUserEditCount'] = $user->getEditCount();
@@ -3068,20 +3148,26 @@ $templates
                        // the client side.
                        $vars['wgUserNewMsgRevisionId'] = $user->getNewMessageRevisionId();
                }
+
                if ( $wgContLang->hasVariants() ) {
                        $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
                }
                // Same test as SkinTemplate
-               $vars['wgIsProbablyEditable'] = $title->quickUserCan( 'edit', $user ) && ( $title->exists() || $title->quickUserCan( 'create', $user ) );
+               $vars['wgIsProbablyEditable'] = $title->quickUserCan( 'edit', $user )
+                       && ( $title->exists() || $title->quickUserCan( 'create', $user ) );
+
                foreach ( $title->getRestrictionTypes() as $type ) {
                        $vars['wgRestriction' . ucfirst( $type )] = $title->getRestrictions( $type );
                }
+
                if ( $title->isMainPage() ) {
                        $vars['wgIsMainPage'] = true;
                }
+
                if ( $this->mRedirectedFrom ) {
                        $vars['wgRedirectedFrom'] = $this->mRedirectedFrom->getPrefixedDBkey();
                }
+
                if ( $relevantUser ) {
                        $vars['wgRelevantUserName'] = $relevantUser->getName();
                }
@@ -3183,13 +3269,13 @@ $templates
                                        'rel' => 'alternate',
                                        'type' => 'application/x-wiki',
                                        'title' => $msg,
-                                       'href' => $this->getTitle()->getLocalURL( 'action=edit' )
+                                       'href' => $this->getTitle()->getEditURL(),
                                ) );
                                // Alternate edit link
                                $tags['alternative-edit'] = Html::element( 'link', array(
                                        'rel' => 'edit',
                                        'title' => $msg,
-                                       'href' => $this->getTitle()->getLocalURL( 'action=edit' )
+                                       'href' => $this->getTitle()->getEditURL(),
                                ) );
                        }
                }
@@ -3199,11 +3285,17 @@ $templates
                # uses whichever one appears later in the HTML source. Make sure
                # apple-touch-icon is specified first to avoid this.
                if ( $wgAppleTouchIcon !== false ) {
-                       $tags['apple-touch-icon'] = Html::element( 'link', array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
+                       $tags['apple-touch-icon'] = Html::element( 'link', array(
+                               'rel' => 'apple-touch-icon',
+                               'href' => $wgAppleTouchIcon
+                       ) );
                }
 
                if ( $wgFavicon !== false ) {
-                       $tags['favicon'] = Html::element( 'link', array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
+                       $tags['favicon'] = Html::element( 'link', array(
+                               'rel' => 'shortcut icon',
+                               'href' => $wgFavicon
+                       ) );
                }
 
                # OpenSearch description link
@@ -3224,7 +3316,11 @@ $templates
                                'type' => 'application/rsd+xml',
                                // Output a protocol-relative URL here if $wgServer is protocol-relative
                                // Whether RSD accepts relative or protocol-relative URLs is completely undocumented, though
-                               'href' => wfExpandUrl( wfAppendQuery( wfScript( 'api' ), array( 'action' => 'rsd' ) ), PROTO_RELATIVE ),
+                               'href' => wfExpandUrl( wfAppendQuery(
+                                       wfScript( 'api' ),
+                                       array( 'action' => 'rsd' ) ),
+                                       PROTO_RELATIVE
+                               ),
                        ) );
                }
 
@@ -3309,7 +3405,8 @@ $templates
                                        $tags[] = $this->feedLink(
                                                $format,
                                                $rctitle->getLocalURL( array( 'feed' => $format ) ),
-                                               $this->msg( "site-{$format}-feed", $wgSitename )->text() # For grep: 'site-rss-feed', 'site-atom-feed'.
+                                               # For grep: 'site-rss-feed', 'site-atom-feed'
+                                               $this->msg( "site-{$format}-feed", $wgSitename )->text()
                                        );
                                }
                        }
@@ -3410,7 +3507,13 @@ $templates
 
                // Add ResourceLoader styles
                // Split the styles into these groups
-               $styles = array( 'other' => array(), 'user' => array(), 'site' => array(), 'private' => array(), 'noscript' => array() );
+               $styles = array(
+                       'other' => array(),
+                       'user' => array(),
+                       'site' => array(),
+                       'private' => array(),
+                       'noscript' => array()
+               );
                $links = array();
                $otherTags = ''; // Tags to append after the normal <link> tags
                $resourceLoader = $this->getResourceLoader();
@@ -3458,16 +3561,20 @@ $templates
                        $styles[ isset( $styles[$group] ) ? $group : 'other' ][] = $name;
                }
 
-               // We want site, private and user styles to override dynamically added styles from modules, but we want
-               // dynamically added styles to override statically added styles from other modules. So the order
-               // has to be other, dynamic, site, private, user
-               // Add statically added styles for other modules
+               // We want site, private and user styles to override dynamically added
+               // styles from modules, but we want dynamically added styles to override
+               // statically added styles from other modules. So the order has to be
+               // other, dynamic, site, private, user. Add statically added styles for
+               // other modules
                $links[] = $this->makeResourceLoaderLink( $styles['other'], ResourceLoaderModule::TYPE_STYLES );
                // Add normal styles added through addStyle()/addInlineStyle() here
                $links[] = implode( "\n", $this->buildCssLinksArray() ) . $this->mInlineStyles;
                // Add marker tag to mark the place where the client-side loader should inject dynamic styles
                // We use a <meta> tag with a made-up name for this because that's valid HTML
-               $links[] = Html::element( 'meta', array( 'name' => 'ResourceLoaderDynamicStyles', 'content' => '' ) ) . "\n";
+               $links[] = Html::element(
+                       'meta',
+                       array( 'name' => 'ResourceLoaderDynamicStyles', 'content' => '' )
+               ) . "\n";
 
                // Add site, private and user styles
                // 'private' at present only contains user.options, so put that before 'user'
@@ -3483,7 +3590,7 @@ $templates
        }
 
        /**
-        * @return Array
+        * @return array
         */
        public function buildCssLinksArray() {
                $links = array();
@@ -3569,8 +3676,10 @@ $templates
                                } elseif ( preg_match( $screenMediaQueryRegex, $media ) === 1 ) {
                                        // This regex will not attempt to understand a comma-separated media_query_list
                                        //
-                                       // Example supported values for $media: 'screen', 'only screen', 'screen and (min-width: 982px)' ),
-                                       // Example NOT supported value for $media: '3d-glasses, screen, print and resolution > 90dpi'
+                                       // Example supported values for $media:
+                                       // 'screen', 'only screen', 'screen and (min-width: 982px)' ),
+                                       // Example NOT supported value for $media:
+                                       // '3d-glasses, screen, print and resolution > 90dpi'
                                        //
                                        // If it's a print request, we never want any kind of screen stylesheets
                                        // If it's a handheld request (currently the only other choice with a switch),
@@ -3604,8 +3713,8 @@ $templates
         * Like addWikiMsg() except the parameters are taken as an array
         * instead of a variable argument list.
         *
-        * @param $name string
-        * @param $args array
+        * @param string $name
+        * @param array $args
         */
        public function addWikiMsgArray( $name, $args ) {
                $this->addHTML( $this->msg( $name, $args )->parseAsBlock() );
@@ -3628,11 +3737,12 @@ $templates
         *
         * Is equivalent to:
         *
-        *    $wgOut->addWikiText( "<div class='error'>\n" . wfMessage( 'some-error' )->plain() . "\n</div>" );
+        *    $wgOut->addWikiText( "<div class='error'>\n"
+        *        . wfMessage( 'some-error' )->plain() . "\n</div>" );
         *
         * The newline after opening div is needed in some wikitext. See bug 19226.
         *
-        * @param $wrap string
+        * @param string $wrap
         */
        public function wrapWikiMsg( $wrap /*, ...*/ ) {
                $msgSpecs = func_get_args();