Merge "Allow querying for multiple MIME types in the allimages API"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 29 Dec 2014 22:04:16 +0000 (22:04 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 29 Dec 2014 22:04:16 +0000 (22:04 +0000)
includes/User.php
includes/api/ApiMain.php
includes/logging/LogFormatter.php
includes/parser/Parser.php
includes/specials/SpecialListgrouprights.php
includes/specials/SpecialUserrights.php
languages/Language.php

index 34af4c5..88004dc 100644 (file)
@@ -4471,7 +4471,7 @@ class User implements IDBAccessObject {
                if ( $title ) {
                        return Linker::link( $title, htmlspecialchars( $text ) );
                } else {
-                       return $text;
+                       return htmlspecialchars( $text );
                }
        }
 
index a5287b6..1544189 100644 (file)
@@ -710,12 +710,14 @@ class ApiMain extends ApiBase {
 
                        $errMessage = array(
                                'code' => 'internal_api_error_' . get_class( $e ),
-                               'info' => $info,
-                       );
-                       ApiResult::setContent(
-                               $errMessage,
-                               $config->get( 'ShowExceptionDetails' ) ? "\n\n{$e->getTraceAsString()}\n\n" : ''
+                               'info' => '[' . MWExceptionHandler::getLogId( $e ) . '] ' . $info,
                        );
+                       if ( $config->get( 'ShowExceptionDetails' ) ) {
+                               ApiResult::setContent(
+                                       $errMessage,
+                                       MWExceptionHandler::getRedactedTraceAsString( $e )
+                               );
+                       }
                }
 
                // Remember all the warnings to re-add them later
index 464b723..c6fcdb0 100644 (file)
@@ -355,8 +355,10 @@ class LogFormatter {
                                $element = $this->styleRestricedElement( $element );
                        }
                } else {
-                       $performer = $this->getPerformerElement() . $this->msg( 'word-separator' )->text();
-                       $element = $performer . $this->getRestrictedElement( 'rev-deleted-event' );
+                       $sep = $this->msg( 'word-separator' );
+                       $sep = $this->plaintext ? $sep->text() : $sep->escaped();
+                       $performer = $this->getPerformerElement();
+                       $element = $performer . $sep . $this->getRestrictedElement( 'rev-deleted-event' );
                }
 
                return $element;
@@ -731,7 +733,9 @@ class LegacyLogFormatter extends LogFormatter {
 
                $performer = $this->getPerformerElement();
                if ( !$this->irctext ) {
-                       $action = $performer . $this->msg( 'word-separator' )->text() . $action;
+                       $sep = $this->msg( 'word-separator' );
+                       $sep = $this->plaintext ? $sep->text() : $sep->escaped();
+                       $action = $performer . $sep . $action;
                }
 
                return $action;
index 6b2444e..b7f8cf2 100644 (file)
@@ -146,7 +146,8 @@ class Parser {
         * @var MagicWordArray
         */
        public $mSubstWords;
-       public $mConf, $mPreprocessor, $mExtLinkBracketedRegex, $mUrlProtocols; # Initialised in constructor
+       # Initialised in constructor
+       public $mConf, $mPreprocessor, $mExtLinkBracketedRegex, $mUrlProtocols;
 
        # Cleared with clearState():
        /**
@@ -633,7 +634,9 @@ class Parser {
         * @param bool|PPFrame $frame
         * @return mixed|string
         */
-       public function preprocess( $text, Title $title = null, ParserOptions $options, $revid = null, $frame = false ) {
+       public function preprocess( $text, Title $title = null,
+               ParserOptions $options, $revid = null, $frame = false
+       ) {
                wfProfileIn( __METHOD__ );
                $magicScopeVariable = $this->lock();
                $this->startParse( $title, $options, self::OT_PREPROCESS, true );
index 8b9a0ee..828a93b 100644 (file)
@@ -86,13 +86,14 @@ class SpecialListGroupRights extends SpecialPage {
                        $grouppageLocalized = !$msg->isBlank() ?
                                $msg->text() :
                                MWNamespace::getCanonicalName( NS_PROJECT ) . ':' . $groupname;
+                       $grouppageLocalizedTitle = Title::newFromText( $grouppageLocalized );
 
-                       if ( $group == '*' ) {
-                               // Do not make a link for the generic * group
+                       if ( $group == '*' || !$grouppageLocalizedTitle ) {
+                               // Do not make a link for the generic * group or group with invalid group page
                                $grouppage = htmlspecialchars( $groupnameLocalized );
                        } else {
                                $grouppage = Linker::link(
-                                       Title::newFromText( $grouppageLocalized ),
+                                       $grouppageLocalizedTitle,
                                        htmlspecialchars( $groupnameLocalized )
                                );
                        }
index 3e9313c..892ff5b 100644 (file)
@@ -493,25 +493,32 @@ class UserrightsPage extends SpecialPage {
                }
 
                $language = $this->getLanguage();
-               $displayedList = $this->msg( 'userrights-groupsmember-type',
-                       $language->listToText( $list ),
-                       $language->listToText( $membersList )
-               )->plain();
-               $displayedAutolist = $this->msg( 'userrights-groupsmember-type',
-                       $language->listToText( $autoList ),
-                       $language->listToText( $autoMembersList )
-               )->plain();
+               $displayedList = $this->msg( 'userrights-groupsmember-type' )
+                       ->rawParams(
+                               $language->listToText( $list ),
+                               $language->listToText( $membersList )
+                       )->escaped();
+               $displayedAutolist = $this->msg( 'userrights-groupsmember-type' )
+                       ->rawParams(
+                               $language->listToText( $autoList ),
+                               $language->listToText( $autoMembersList )
+                       )->escaped();
 
                $grouplist = '';
                $count = count( $list );
                if ( $count > 0 ) {
-                       $grouplist = $this->msg( 'userrights-groupsmember', $count, $user->getName() )->parse();
+                       $grouplist = $this->msg( 'userrights-groupsmember' )
+                               ->numParams( $count )
+                               ->params( $user->getName() )
+                               ->parse();
                        $grouplist = '<p>' . $grouplist . ' ' . $displayedList . "</p>\n";
                }
 
                $count = count( $autoList );
                if ( $count > 0 ) {
-                       $autogrouplistintro = $this->msg( 'userrights-groupsmember-auto', $count, $user->getName() )
+                       $autogrouplistintro = $this->msg( 'userrights-groupsmember-auto' )
+                               ->numParams( $count )
+                               ->params( $user->getName() )
                                ->parse();
                        $grouplist .= '<p>' . $autogrouplistintro . ' ' . $displayedAutolist . "</p>\n";
                }
@@ -669,9 +676,9 @@ class UserrightsPage extends SpecialPage {
 
                                $member = User::getGroupMember( $group, $user->getName() );
                                if ( $checkbox['irreversible'] ) {
-                                       $text = $this->msg( 'userrights-irreversible-marker', $member )->escaped();
+                                       $text = $this->msg( 'userrights-irreversible-marker', $member )->text();
                                } else {
-                                       $text = htmlspecialchars( $member );
+                                       $text = $member;
                                }
                                $checkboxHtml = Xml::checkLabel( $text, "wpGroup-" . $group,
                                        "wpGroup-" . $group, $checkbox['set'], $attr );
index 93c186c..72cc1ac 100644 (file)
@@ -962,7 +962,17 @@ class Language {
         * @return string
         */
        function getMessageFromDB( $msg ) {
-               return wfMessage( $msg )->inLanguage( $this )->text();
+               return $this->msg( $msg )->text();
+       }
+
+       /**
+        * Get message object in this language. Only for use inside this class.
+        *
+        * @param string $msg Message name
+        * @return Message
+        */
+       protected function msg( $msg ) {
+               return wfMessage( $msg )->inLanguage( $this );
        }
 
        /**
@@ -3406,10 +3416,10 @@ class Language {
                        return '';
                }
                if ( $m > 0 ) {
-                       $and = $this->getMessageFromDB( 'and' );
-                       $space = $this->getMessageFromDB( 'word-separator' );
+                       $and = $this->msg( 'and' )->escaped();
+                       $space = $this->msg( 'word-separator' )->escaped();
                        if ( $m > 1 ) {
-                               $comma = $this->getMessageFromDB( 'comma-separator' );
+                               $comma = $this->msg( 'comma-separator' )->escaped();
                        }
                }
                $s = $l[$m];
@@ -4643,17 +4653,22 @@ class Language {
         * Make a list item, used by various special pages
         *
         * @param string $page Page link
-        * @param string $details Text between brackets
+        * @param string $details HTML safe text between brackets
         * @param bool $oppositedm Add the direction mark opposite to your
         *   language, to display text properly
-        * @return string
+        * @return HTML escaped string
         */
        function specialList( $page, $details, $oppositedm = true ) {
-               $dirmark = ( $oppositedm ? $this->getDirMark( true ) : '' ) .
-                       $this->getDirMark();
-               $details = $details ? $dirmark . $this->getMessageFromDB( 'word-separator' ) .
-                       wfMessage( 'parentheses' )->rawParams( $details )->inLanguage( $this )->escaped() : '';
-               return $page . $details;
+               if ( !$details ) {
+                       return $page;
+               }
+
+               $dirmark = ( $oppositedm ? $this->getDirMark( true ) : '' ) . $this->getDirMark();
+               return
+                       $page .
+                       $dirmark .
+                       $this->msg( 'word-separator' )->escaped() .
+                       $this->msg( 'parentheses' )->rawParams( $details )->escaped();
        }
 
        /**