Merge "Fix MessagecacheTest::testLoadFromDB_fetchLatestRevision"
[lhc/web/wiklou.git] / includes / Linker.php
index 049fb07..decc13c 100644 (file)
@@ -112,7 +112,7 @@ class Linker {
                if ( $html !== null ) {
                        $text = new HtmlArmor( $html );
                } else {
-                       $text = $html; // null
+                       $text = null;
                }
 
                if ( in_array( 'known', $options, true ) ) {
@@ -823,13 +823,20 @@ class Linker {
 
        /**
         * Make an external link
+        *
         * @since 1.16.3. $title added in 1.21
         * @param string $url URL to link to
+        * @param-taint $url escapes_html
         * @param string $text Text of link
+        * @param-taint $text escapes_html
         * @param bool $escape Do we escape the link text?
+        * @param-taint $escape none
         * @param string $linktype Type of external link. Gets added to the classes
+        * @param-taint $linktype escapes_html
         * @param array $attribs Array of extra attributes to <a>
+        * @param-taint $attribs escapes_html
         * @param Title|null $title Title object used for title specific link attributes
+        * @param-taint $title none
         * @return string
         */
        public static function makeExternalLink( $url, $text, $escape = true,
@@ -1600,9 +1607,8 @@ class Linker {
         * @return string Full html of the TOC
         */
        public static function tocList( $toc, $lang = null ) {
-               global $wgLang;
-               $lang = $lang ?? $wgLang;
-               if ( !is_object( $lang ) ) {
+               $lang = $lang ?? RequestContext::getMain()->getLanguage();
+               if ( !$lang instanceof Language ) {
                        wfDeprecated( __METHOD__ . ' with type other than Language for $lang', '1.33' );
                        $lang = wfGetLangObj( $lang );
                }
@@ -1704,12 +1710,8 @@ class Linker {
        static function splitTrail( $trail ) {
                $regex = MediaWikiServices::getInstance()->getContentLanguage()->linkTrail();
                $inside = '';
-               if ( $trail !== '' ) {
-                       $m = [];
-                       if ( preg_match( $regex, $trail, $m ) ) {
-                               $inside = $m[1];
-                               $trail = $m[2];
-                       }
+               if ( $trail !== '' && preg_match( $regex, $trail, $m ) ) {
+                       list( , $inside, $trail ) = $m;
                }
                return [ $inside, $trail ];
        }
@@ -1762,6 +1764,20 @@ class Linker {
                        $inner = $context->msg( 'brackets' )->rawParams( $inner )->escaped();
                }
 
+               /**
+                * FIXME
+                * Remove all references to DisableRollbackConfirmationFeature
+                * after release of rollback feature. See T199534
+                */
+               if ( !MediaWikiServices::getInstance()
+                               ->getMainConfig()->get( 'DisableRollbackConfirmationFeature' ) &&
+                        $context->getUser()->getBoolOption( 'showrollbackconfirmation' )
+               ) {
+                       $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
+                       $stats->increment( 'rollbackconfirmation.event.load' );
+                       $context->getOutput()->addModules( 'mediawiki.page.rollback.confirmation' );
+               }
+
                return '<span class="mw-rollback-link">' . $inner . '</span>';
        }
 
@@ -1855,20 +1871,24 @@ class Linker {
                }
 
                $title = $rev->getTitle();
+
                $query = [
                        'action' => 'rollback',
                        'from' => $rev->getUserText(),
                        'token' => $context->getUser()->getEditToken( 'rollback' ),
                ];
+
                $attrs = [
                        'data-mw' => 'interface',
-                       'title' => $context->msg( 'tooltip-rollback' )->text(),
+                       'title' => $context->msg( 'tooltip-rollback' )->text()
                ];
+
                $options = [ 'known', 'noclasses' ];
 
                if ( $context->getRequest()->getBool( 'bot' ) ) {
+                       //T17999
+                       $query['hidediff'] = '1';
                        $query['bot'] = '1';
-                       $query['hidediff'] = '1'; // T17999
                }
 
                $disableRollbackEditCount = false;