Merge "UserTest: Cover User::isIP and User::isValidUserName better"
[lhc/web/wiklou.git] / includes / Linker.php
index 894c97d..7d88f25 100644 (file)
@@ -30,7 +30,6 @@
  * @ingroup Skins
  */
 class Linker {
-
        /**
         * Flags for userToolLinks()
         */
@@ -44,7 +43,8 @@ class Linker {
         * @param string $class The contents of the class attribute; if an empty
         *   string is passed, which is the default value, defaults to 'external'.
         * @return string
-        * @deprecated since 1.18 Just pass the external class directly to something using Html::expandAttributes
+        * @deprecated since 1.18 Just pass the external class directly to something
+        *   using Html::expandAttributes.
         */
        static function getExternalLinkAttributes( $class = 'external' ) {
                wfDeprecated( __METHOD__, '1.18' );
@@ -389,13 +389,15 @@ class Linker {
                if ( $target->getPrefixedText() === '' && $target->hasFragment() ) {
                        return htmlspecialchars( $target->getFragment() );
                }
+
                return htmlspecialchars( $target->getPrefixedText() );
        }
 
        /**
-        * Make appropriate markup for a link to the current article. This is currently rendered
-        * as the bold link text. The calling sequence is the same as the other make*LinkObj static functions,
-        * despite $query not being used.
+        * Make appropriate markup for a link to the current article. This is
+        * currently rendered as the bold link text. The calling sequence is the
+        * same as the other make*LinkObj static functions, despite $query not
+        * being used.
         *
         * @param Title $nt
         * @param string $html [optional]
@@ -403,10 +405,14 @@ class Linker {
         * @param string $trail [optional]
         * @param string $prefix [optional]
         *
-        *
         * @return string
         */
        public static function makeSelfLinkObj( $nt, $html = '', $query = '', $trail = '', $prefix = '' ) {
+               $ret = "<strong class=\"selflink\">{$prefix}{$html}</strong>{$trail}";
+               if ( !wfRunHooks( 'SelfLinkBegin', array( $nt, &$html, &$trail, &$prefix, &$ret ) ) ) {
+                       return $ret;
+               }
+
                if ( $html == '' ) {
                        $html = htmlspecialchars( $nt->getPrefixedText() );
                }
@@ -491,7 +497,8 @@ class Linker {
                $img = '';
                $success = wfRunHooks( 'LinkerMakeExternalImage', array( &$url, &$alt, &$img ) );
                if ( !$success ) {
-                       wfDebug( "Hook LinkerMakeExternalImage changed the output of external image with url {$url} and alt text {$alt} to {$img}\n", true );
+                       wfDebug( "Hook LinkerMakeExternalImage changed the output of external image "
+                               . "with url {$url} and alt text {$alt} to {$img}\n", true );
                        return $img;
                }
                return Html::element( 'img',
@@ -536,8 +543,9 @@ class Linker {
         * @since 1.20
         * @return string HTML for an image, with links, wrappers, etc.
         */
-       public static function makeImageLink( /*Parser*/ $parser, Title $title, $file, $frameParams = array(),
-               $handlerParams = array(), $time = false, $query = "", $widthOption = null
+       public static function makeImageLink( /*Parser*/ $parser, Title $title,
+               $file, $frameParams = array(), $handlerParams = array(), $time = false,
+               $query = "", $widthOption = null
        ) {
                $res = null;
                $dummy = new DummyLinker;
@@ -587,8 +595,14 @@ class Linker {
                                $hp['width'] = $file->getWidth( $page );
                        }
 
-                       if ( isset( $fp['thumbnail'] ) || isset( $fp['manualthumb'] ) || isset( $fp['framed'] ) || isset( $fp['frameless'] ) || !$hp['width'] ) {
+                       if ( isset( $fp['thumbnail'] )
+                               || isset( $fp['manualthumb'] )
+                               || isset( $fp['framed'] )
+                               || isset( $fp['frameless'] )
+                               || !$hp['width']
+                       ) {
                                global $wgThumbLimits, $wgThumbUpright;
+
                                if ( $widthOption === null || !isset( $wgThumbLimits[$widthOption] ) ) {
                                        $widthOption = User::getDefaultOption( 'thumbsize' );
                                }
@@ -597,7 +611,10 @@ class Linker {
                                if ( isset( $fp['upright'] ) && $fp['upright'] == 0 ) {
                                        $fp['upright'] = $wgThumbUpright;
                                }
-                               // For caching health: If width scaled down due to upright parameter, round to full __0 pixel to avoid the creation of a lot of odd thumbs
+
+                               // For caching health: If width scaled down due to upright
+                               // parameter, round to full __0 pixel to avoid the creation of a
+                               // lot of odd thumbs.
                                $prefWidth = isset( $fp['upright'] ) ?
                                        round( $wgThumbLimits[$widthOption] * $fp['upright'], -1 ) :
                                        $wgThumbLimits[$widthOption];
@@ -632,8 +649,9 @@ class Linker {
 
                if ( $file && isset( $fp['frameless'] ) ) {
                        $srcWidth = $file->getWidth( $page );
-                       # For "frameless" option: do not present an image bigger than the source (for bitmap-style images)
-                       # This is the same behavior as the "thumb" option does it already.
+                       # For "frameless" option: do not present an image bigger than the
+                       # source (for bitmap-style images). This is the same behavior as the
+                       # "thumb" option does it already.
                        if ( $srcWidth && !$file->mustRender() && $hp['width'] > $srcWidth ) {
                                $hp['width'] = $srcWidth;
                        }
@@ -831,7 +849,9 @@ class Linker {
                        $fp['link-url'] = $url;
                }
 
-               $s = "<div class=\"thumb t{$fp['align']}\"><div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">";
+               $s = "<div class=\"thumb t{$fp['align']}\">"
+                       . "<div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">";
+
                if ( !$exists ) {
                        $s .= self::makeBrokenImageLinkObj( $title, $fp['title'], '', '', '', $time == true );
                        $zoomIcon = '';
@@ -845,7 +865,9 @@ class Linker {
                        $params = array(
                                'alt' => $fp['alt'],
                                'title' => $fp['title'],
-                               'img-class' => ( isset( $fp['class'] ) && $fp['class'] !== '' ? $fp['class'] . ' ' : '' ) . 'thumbimage'
+                               'img-class' => ( isset( $fp['class'] ) && $fp['class'] !== ''
+                                       ? $fp['class'] . ' '
+                                       : '' ) . 'thumbimage'
                        );
                        $params = self::getImageLinkMTOParams( $fp, $query ) + $params;
                        $s .= $thumb->toHtml( $params );
@@ -858,7 +880,8 @@ class Linker {
                                                'class' => 'internal',
                                                'title' => wfMessage( 'thumbnail-more' )->text() ),
                                                Html::element( 'img', array(
-                                                       'src' => $wgStylePath . '/common/images/magnify-clip' . ( $wgContLang->isRTL() ? '-rtl' : '' ) . '.png',
+                                                       'src' => $wgStylePath . '/common/images/magnify-clip'
+                                                               . ( $wgContLang->isRTL() ? '-rtl' : '' ) . '.png',
                                                        'width' => 15,
                                                        'height' => 11,
                                                        'alt' => "" ) ) ) );
@@ -910,7 +933,9 @@ class Linker {
         * @param bool $time A file of a certain timestamp was requested
         * @return string
         */
-       public static function makeBrokenImageLinkObj( $title, $label = '', $query = '', $unused1 = '', $unused2 = '', $time = false ) {
+       public static function makeBrokenImageLinkObj( $title, $label = '',
+               $query = '', $unused1 = '', $unused2 = '', $time = false
+       ) {
                global $wgEnableUploads, $wgUploadMissingFileUrl, $wgUploadNavigationUrl;
                if ( ! $title instanceof Title ) {
                        return "<!-- ERROR -->" . htmlspecialchars( $label );
@@ -922,7 +947,9 @@ class Linker {
                $encLabel = htmlspecialchars( $label );
                $currentExists = $time ? ( wfFindFile( $title ) != false ) : false;
 
-               if ( ( $wgUploadMissingFileUrl || $wgUploadNavigationUrl || $wgEnableUploads ) && !$currentExists ) {
+               if ( ( $wgUploadMissingFileUrl || $wgUploadNavigationUrl || $wgEnableUploads )
+                       && !$currentExists
+               ) {
                        $redir = RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title );
 
                        if ( $redir ) {
@@ -1013,7 +1040,8 @@ class Linker {
 
                if ( !wfRunHooks( 'LinkerMakeMediaLinkFile',
                        array( $title, $file, &$html, &$attribs, &$ret ) ) ) {
-                       wfDebug( "Hook LinkerMakeMediaLinkFile changed the output of link with url {$url} and text {$html} to {$ret}\n", true );
+                       wfDebug( "Hook LinkerMakeMediaLinkFile changed the output of link "
+                               . "with url {$url} and text {$html} to {$ret}\n", true );
                        return $ret;
                }
 
@@ -1047,7 +1075,9 @@ class Linker {
         * @param Title|null $title Title object used for title specific link attributes
         * @return string
         */
-       public static function makeExternalLink( $url, $text, $escape = true, $linktype = '', $attribs = array(), $title = null ) {
+       public static function makeExternalLink( $url, $text, $escape = true,
+               $linktype = '', $attribs = array(), $title = null
+       ) {
                global $wgTitle;
                $class = "external";
                if ( $linktype ) {
@@ -1070,7 +1100,8 @@ class Linker {
                $success = wfRunHooks( 'LinkerMakeExternalLink',
                        array( &$url, &$text, &$link, &$attribs, $linktype ) );
                if ( !$success ) {
-                       wfDebug( "Hook LinkerMakeExternalLink changed the output of link with url {$url} and text {$text} to {$link}\n", true );
+                       wfDebug( "Hook LinkerMakeExternalLink changed the output of link "
+                               . "with url {$url} and text {$text} to {$link}\n", true );
                        return $link;
                }
                $attribs['href'] = $url;
@@ -1111,7 +1142,8 @@ class Linker {
         * @param string $userText User name or IP address
         * @param bool $redContribsWhenNoEdits Should the contributions link be
         *   red if the user has no edits?
-        * @param int $flags Customisation flags (e.g. Linker::TOOL_LINKS_NOBLOCK and Linker::TOOL_LINKS_EMAIL)
+        * @param int $flags Customisation flags (e.g. Linker::TOOL_LINKS_NOBLOCK
+        *   and Linker::TOOL_LINKS_EMAIL).
         * @param int $edits User edit count (optional, for performance)
         * @return string HTML fragment
         */
@@ -1285,12 +1317,6 @@ class Linker {
                return $comment;
        }
 
-       /**
-        * @var Title
-        */
-       static $autocommentTitle;
-       static $autocommentLocal;
-
        /**
         * Converts autogenerated comments in edit summaries into section links.
         * The pattern for autogen comments is / * foo * /, which makes for
@@ -1305,79 +1331,59 @@ class Linker {
         * @return string Formatted comment
         */
        private static function formatAutocomments( $comment, $title = null, $local = false ) {
-               // Bah!
-               self::$autocommentTitle = $title;
-               self::$autocommentLocal = $local;
-               $comment = preg_replace_callback(
+               return preg_replace_callback(
                        '!(.*)/\*\s*(.*?)\s*\*/(.*)!',
-                       array( 'Linker', 'formatAutocommentsCallback' ),
-                       $comment );
-               self::$autocommentTitle = null;
-               self::$autocommentLocal = null;
-               return $comment;
-       }
-
-       /**
-        * Helper function for Linker::formatAutocomments
-        * @param array $match
-        * @return string
-        */
-       private static function formatAutocommentsCallback( $match ) {
-               global $wgLang;
-               $title = self::$autocommentTitle;
-               $local = self::$autocommentLocal;
-
-               $pre = $match[1];
-               $auto = $match[2];
-               $post = $match[3];
-               $comment = null;
-               wfRunHooks( 'FormatAutocomments', array( &$comment, $pre, $auto, $post, $title, $local ) );
-               if ( $comment === null ) {
-                       $link = '';
-                       if ( $title ) {
-                               $section = $auto;
-
-                               # Remove links that a user may have manually put in the autosummary
-                               # This could be improved by copying as much of Parser::stripSectionName as desired.
-                               $section = str_replace( '[[:', '', $section );
-                               $section = str_replace( '[[', '', $section );
-                               $section = str_replace( ']]', '', $section );
-
-                               $section = Sanitizer::normalizeSectionNameWhitespace( $section ); # bug 22784
-                               if ( $local ) {
-                                       $sectionTitle = Title::newFromText( '#' . $section );
-                               } else {
-                                       $sectionTitle = Title::makeTitleSafe( $title->getNamespace(),
-                                               $title->getDBkey(), $section );
-                               }
-                               if ( $sectionTitle ) {
-                                       $link = self::link( $sectionTitle,
-                                               $wgLang->getArrow(), array(), array(),
-                                               'noclasses' );
-                               } else {
+                       function ( $match ) use ( $title, $local ) {
+                               global $wgLang;
+
+                               $pre = $match[1];
+                               $auto = $match[2];
+                               $post = $match[3];
+                               $comment = null;
+                               wfRunHooks( 'FormatAutocomments', array( &$comment, $pre, $auto, $post, $title, $local ) );
+                               if ( $comment === null ) {
                                        $link = '';
+                                       if ( $title ) {
+                                               $section = $auto;
+                                               # Remove links that a user may have manually put in the autosummary
+                                               # This could be improved by copying as much of Parser::stripSectionName as desired.
+                                               $section = str_replace( '[[:', '', $section );
+                                               $section = str_replace( '[[', '', $section );
+                                               $section = str_replace( ']]', '', $section );
+
+                                               $section = Sanitizer::normalizeSectionNameWhitespace( $section ); # bug 22784
+                                               if ( $local ) {
+                                                       $sectionTitle = Title::newFromText( '#' . $section );
+                                               } else {
+                                                       $sectionTitle = Title::makeTitleSafe( $title->getNamespace(),
+                                                               $title->getDBkey(), $section );
+                                               }
+                                               if ( $sectionTitle ) {
+                                                       $link = Linker::link( $sectionTitle,
+                                                               $wgLang->getArrow(), array(), array(),
+                                                               'noclasses' );
+                                               } else {
+                                                       $link = '';
+                                               }
+                                       }
+                                       if ( $pre ) {
+                                               # written summary $presep autocomment (summary /* section */)
+                                               $pre .= wfMessage( 'autocomment-prefix' )->inContentLanguage()->escaped();
+                                       }
+                                       if ( $post ) {
+                                               # autocomment $postsep written summary (/* section */ summary)
+                                               $auto .= wfMessage( 'colon-separator' )->inContentLanguage()->escaped();
+                                       }
+                                       $auto = '<span class="autocomment">' . $auto . '</span>';
+                                       $comment = $pre . $link . $wgLang->getDirMark()
+                                               . '<span dir="auto">' . $auto . $post . '</span>';
                                }
-                       }
-                       if ( $pre ) {
-                               # written summary $presep autocomment (summary /* section */)
-                               $pre .= wfMessage( 'autocomment-prefix' )->inContentLanguage()->escaped();
-                       }
-                       if ( $post ) {
-                               # autocomment $postsep written summary (/* section */ summary)
-                               $auto .= wfMessage( 'colon-separator' )->inContentLanguage()->escaped();
-                       }
-                       $auto = '<span class="autocomment">' . $auto . '</span>';
-                       $comment = $pre . $link . $wgLang->getDirMark() . '<span dir="auto">' . $auto . $post . '</span>';
-               }
-               return $comment;
+                               return $comment;
+               },
+                       $comment
+               );
        }
 
-       /**
-        * @var Title
-        */
-       static $commentContextTitle;
-       static $commentLocal;
-
        /**
         * Formats wiki links and media links in text; all other wiki formatting
         * is ignored
@@ -1389,9 +1395,7 @@ class Linker {
         * @return string
         */
        public static function formatLinksInComment( $comment, $title = null, $local = false ) {
-               self::$commentContextTitle = $title;
-               self::$commentLocal = $local;
-               $html = preg_replace_callback(
+               return preg_replace_callback(
                        '/
                                \[\[
                                :? # ignore optional leading colon
@@ -1404,83 +1408,79 @@ class Linker {
                                \]\]
                                ([^[]*) # 3. link trail (the text up until the next link)
                        /x',
-                       array( 'Linker', 'formatLinksInCommentCallback' ),
-                       $comment );
-               self::$commentContextTitle = null;
-               self::$commentLocal = null;
-               return $html;
-       }
-
-       /**
-        * @param array $match
-        * @return mixed
-        */
-       protected static function formatLinksInCommentCallback( $match ) {
-               global $wgContLang;
+                       function ( $match ) use ( $title, $local ) {
+                               global $wgContLang;
 
-               $medians = '(?:' . preg_quote( MWNamespace::getCanonicalName( NS_MEDIA ), '/' ) . '|';
-               $medians .= preg_quote( $wgContLang->getNsText( NS_MEDIA ), '/' ) . '):';
+                               $medians = '(?:' . preg_quote( MWNamespace::getCanonicalName( NS_MEDIA ), '/' ) . '|';
+                               $medians .= preg_quote( $wgContLang->getNsText( NS_MEDIA ), '/' ) . '):';
 
-               $comment = $match[0];
+                               $comment = $match[0];
 
-               # fix up urlencoded title texts (copied from Parser::replaceInternalLinks)
-               if ( strpos( $match[1], '%' ) !== false ) {
-                       $match[1] = str_replace( array( '<', '>' ), array( '&lt;', '&gt;' ), rawurldecode( $match[1] ) );
-               }
+                               # fix up urlencoded title texts (copied from Parser::replaceInternalLinks)
+                               if ( strpos( $match[1], '%' ) !== false ) {
+                                       $match[1] = str_replace( array( '<', '>' ), array( '&lt;', '&gt;' ), rawurldecode( $match[1] ) );
+                               }
 
-               # Handle link renaming [[foo|text]] will show link as "text"
-               if ( $match[2] != "" ) {
-                       $text = $match[2];
-               } else {
-                       $text = $match[1];
-               }
-               $submatch = array();
-               $thelink = null;
-               if ( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
-                       # Media link; trail not supported.
-                       $linkRegexp = '/\[\[(.*?)\]\]/';
-                       $title = Title::makeTitleSafe( NS_FILE, $submatch[1] );
-                       if ( $title ) {
-                               $thelink = self::makeMediaLinkObj( $title, $text );
-                       }
-               } else {
-                       # Other kind of link
-                       if ( preg_match( $wgContLang->linkTrail(), $match[3], $submatch ) ) {
-                               $trail = $submatch[1];
-                       } else {
-                               $trail = "";
-                       }
-                       $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
-                       if ( isset( $match[1][0] ) && $match[1][0] == ':' ) {
-                               $match[1] = substr( $match[1], 1 );
-                       }
-                       list( $inside, $trail ) = self::splitTrail( $trail );
-
-                       $linkText = $text;
-                       $linkTarget = self::normalizeSubpageLink( self::$commentContextTitle,
-                               $match[1], $linkText );
-
-                       $target = Title::newFromText( $linkTarget );
-                       if ( $target ) {
-                               if ( $target->getText() == '' && !$target->isExternal()
-                                       && !self::$commentLocal && self::$commentContextTitle
-                               ) {
-                                       $newTarget = clone ( self::$commentContextTitle );
-                                       $newTarget->setFragment( '#' . $target->getFragment() );
-                                       $target = $newTarget;
+                               # Handle link renaming [[foo|text]] will show link as "text"
+                               if ( $match[2] != "" ) {
+                                       $text = $match[2];
+                               } else {
+                                       $text = $match[1];
+                               }
+                               $submatch = array();
+                               $thelink = null;
+                               if ( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
+                                       # Media link; trail not supported.
+                                       $linkRegexp = '/\[\[(.*?)\]\]/';
+                                       $title = Title::makeTitleSafe( NS_FILE, $submatch[1] );
+                                       if ( $title ) {
+                                               $thelink = Linker::makeMediaLinkObj( $title, $text );
+                                       }
+                               } else {
+                                       # Other kind of link
+                                       if ( preg_match( $wgContLang->linkTrail(), $match[3], $submatch ) ) {
+                                               $trail = $submatch[1];
+                                       } else {
+                                               $trail = "";
+                                       }
+                                       $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
+                                       if ( isset( $match[1][0] ) && $match[1][0] == ':' ) {
+                                               $match[1] = substr( $match[1], 1 );
+                                       }
+                                       list( $inside, $trail ) = Linker::splitTrail( $trail );
+
+                                       $linkText = $text;
+                                       $linkTarget = Linker::normalizeSubpageLink( $title, $match[1], $linkText );
+
+                                       $target = Title::newFromText( $linkTarget );
+                                       if ( $target ) {
+                                               if ( $target->getText() == '' && !$target->isExternal()
+                                                       && !$local && $title
+                                               ) {
+                                                       $newTarget = clone ( $title );
+                                                       $newTarget->setFragment( '#' . $target->getFragment() );
+                                                       $target = $newTarget;
+                                               }
+                                               $thelink = Linker::link(
+                                                       $target,
+                                                       $linkText . $inside
+                                               ) . $trail;
+                                       }
+                               }
+                               if ( $thelink ) {
+                                       // If the link is still valid, go ahead and replace it in!
+                                       $comment = preg_replace(
+                                               $linkRegexp,
+                                               StringUtils::escapeRegexReplacement( $thelink ),
+                                               $comment,
+                                               1
+                                       );
                                }
-                               $thelink = self::link(
-                                       $target,
-                                       $linkText . $inside
-                               ) . $trail;
-                       }
-               }
-               if ( $thelink ) {
-                       // If the link is still valid, go ahead and replace it in!
-                       $comment = preg_replace( $linkRegexp, StringUtils::escapeRegexReplacement( $thelink ), $comment, 1 );
-               }
 
-               return $comment;
+                               return $comment;
+                       },
+                       $comment
+               );
        }
 
        /**
@@ -1736,7 +1736,9 @@ class Linker {
         *
         * @return string HTML headline
         */
-       public static function makeHeadline( $level, $attribs, $anchor, $html, $link, $legacyAnchor = false ) {
+       public static function makeHeadline( $level, $attribs, $anchor, $html,
+               $link, $legacyAnchor = false
+       ) {
                $ret = "<h$level$attribs"
                        . "<span class=\"mw-headline\" id=\"$anchor\">$html</span>"
                        . $link
@@ -1792,10 +1794,13 @@ class Linker {
         * @param array $options
         * @return string
         */
-       public static function generateRollback( $rev, IContextSource $context = null, $options = array( 'verify' ) ) {
+       public static function generateRollback( $rev, IContextSource $context = null,
+               $options = array( 'verify' )
+       ) {
                if ( $context === null ) {
                        $context = RequestContext::getMain();
                }
+
                $editCount = false;
                if ( in_array( 'verify', $options ) ) {
                        $editCount = self::getRollbackEditCount( $rev, true );
@@ -1855,9 +1860,13 @@ class Linker {
                $moreRevs = false;
                foreach ( $res as $row ) {
                        if ( $rev->getRawUserText() != $row->rev_user_text ) {
-                               if ( $verify && ( $row->rev_deleted & Revision::DELETED_TEXT || $row->rev_deleted & Revision::DELETED_USER ) ) {
-                                       // If the user or the text of the revision we might rollback to is deleted in some way we can't rollback
-                                       // Similar to the sanity checks in WikiPage::commitRollback
+                               if ( $verify &&
+                                       ( $row->rev_deleted & Revision::DELETED_TEXT
+                                               || $row->rev_deleted & Revision::DELETED_USER
+                               ) ) {
+                                       // If the user or the text of the revision we might rollback
+                                       // to is deleted in some way we can't rollback. Similar to
+                                       // the sanity checks in WikiPage::commitRollback.
                                        return false;
                                }
                                $moreRevs = true;
@@ -1883,7 +1892,9 @@ class Linker {
         * @param int $editCount Number of edits that would be reverted
         * @return string HTML fragment
         */
-       public static function buildRollbackLink( $rev, IContextSource $context = null, $editCount = false ) {
+       public static function buildRollbackLink( $rev, IContextSource $context = null,
+               $editCount = false
+       ) {
                global $wgShowRollbackEditCount, $wgMiserMode;
 
                // To config which pages are effected by miser mode
@@ -1897,7 +1908,10 @@ class Linker {
                $query = array(
                        'action' => 'rollback',
                        'from' => $rev->getUserText(),
-                       'token' => $context->getUser()->getEditToken( array( $title->getPrefixedText(), $rev->getUserText() ) ),
+                       'token' => $context->getUser()->getEditToken( array(
+                               $title->getPrefixedText(),
+                               $rev->getUserText()
+                       ) ),
                );
                if ( $context->getRequest()->getBool( 'bot' ) ) {
                        $query['bot'] = '1';
@@ -1914,13 +1928,17 @@ class Linker {
                        }
                }
 
-               if ( !$disableRollbackEditCount && is_int( $wgShowRollbackEditCount ) && $wgShowRollbackEditCount > 0 ) {
+               if ( !$disableRollbackEditCount
+                       && is_int( $wgShowRollbackEditCount )
+                       && $wgShowRollbackEditCount > 0
+               ) {
                        if ( !is_numeric( $editCount ) ) {
                                $editCount = self::getRollbackEditCount( $rev, false );
                        }
 
                        if ( $editCount > $wgShowRollbackEditCount ) {
-                               $editCount_output = $context->msg( 'rollbacklinkcount-morethan' )->numParams( $wgShowRollbackEditCount )->parse();
+                               $editCount_output = $context->msg( 'rollbacklinkcount-morethan' )
+                                       ->numParams( $wgShowRollbackEditCount )->parse();
                        } else {
                                $editCount_output = $context->msg( 'rollbacklinkcount' )->numParams( $editCount )->parse();
                        }
@@ -1958,7 +1976,9 @@ class Linker {
         * @param Title|Message|string|null $more An escaped link for "More..." of the templates
         * @return string HTML output
         */
-       public static function formatTemplates( $templates, $preview = false, $section = false, $more = null ) {
+       public static function formatTemplates( $templates, $preview = false,
+               $section = false, $more = null
+       ) {
                global $wgLang;
                wfProfileIn( __METHOD__ );
 
@@ -2062,7 +2082,10 @@ class Linker {
                        $outText .= "</div><ul>\n";
 
                        foreach ( $hiddencats as $titleObj ) {
-                               $outText .= '<li>' . self::link( $titleObj, null, array(), array(), 'known' ) . "</li>\n"; # If it's hidden, it must exist - no need to check with a LinkBatch
+                               # If it's hidden, it must exist - no need to check with a LinkBatch
+                               $outText .= '<li>'
+                                       . self::link( $titleObj, null, array(), array(), 'known' )
+                                       . "</li>\n";
                        }
                        $outText .= '</ul>';
                }
@@ -2128,7 +2151,7 @@ class Linker {
                return $tooltip;
        }
 
-       static $accesskeycache;
+       private static $accesskeycache;
 
        /**
         * Given the id of an interface element, constructs the appropriate
@@ -2225,7 +2248,11 @@ class Linker {
                $html = wfMessage( $msgKey )->escaped();
                $tag = $restricted ? 'strong' : 'span';
                $link = self::link( $sp, $html, array(), $query, array( 'known', 'noclasses' ) );
-               return Xml::tags( $tag, array( 'class' => 'mw-revdelundel-link' ), wfMessage( 'parentheses' )->rawParams( $link )->escaped() );
+               return Xml::tags(
+                       $tag,
+                       array( 'class' => 'mw-revdelundel-link' ),
+                       wfMessage( 'parentheses' )->rawParams( $link )->escaped()
+               );
        }
 
        /**