aboutsummaryrefslogtreecommitdiffstats
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/ParamValidator/TypeDef/TagsDef.php7
-rw-r--r--includes/Rest/Handler/ActionModuleBasedHandler.php13
-rw-r--r--includes/Rest/Handler/EditHandler.php12
-rw-r--r--includes/Rest/Handler/Helper/RestStatusTrait.php28
-rw-r--r--includes/Rest/Handler/UpdateHandler.php2
-rw-r--r--includes/api/Validator/ApiParamValidator.php13
-rw-r--r--includes/api/Validator/ApiParamValidatorCallbacks.php9
-rw-r--r--includes/page/RollbackPage.php4
-rw-r--r--includes/parser/ParserOutput.php6
9 files changed, 19 insertions, 75 deletions
diff --git a/includes/ParamValidator/TypeDef/TagsDef.php b/includes/ParamValidator/TypeDef/TagsDef.php
index 5ffd36fdacab..26e40718cfce 100644
--- a/includes/ParamValidator/TypeDef/TagsDef.php
+++ b/includes/ParamValidator/TypeDef/TagsDef.php
@@ -4,7 +4,6 @@ namespace MediaWiki\ParamValidator\TypeDef;
use ChangeTags;
use MediaWiki\ChangeTags\ChangeTagsStore;
-use MediaWiki\Message\Converter as MessageConverter;
use Wikimedia\Message\DataMessageValue;
use Wikimedia\ParamValidator\Callbacks;
use Wikimedia\ParamValidator\TypeDef\EnumDef;
@@ -25,13 +24,9 @@ class TagsDef extends EnumDef {
private ChangeTagsStore $changeTagsStore;
- /** @var MessageConverter */
- private $messageConverter;
-
public function __construct( Callbacks $callbacks, ChangeTagsStore $changeTagsStore ) {
parent::__construct( $callbacks );
$this->changeTagsStore = $changeTagsStore;
- $this->messageConverter = new MessageConverter();
}
public function validate( $name, $value, array $settings, array $options ) {
@@ -49,7 +44,7 @@ class TagsDef extends EnumDef {
}
if ( !$tagsStatus->isGood() ) {
- $msg = $this->messageConverter->convertMessage( $tagsStatus->getMessage() );
+ $msg = $tagsStatus->getMessage();
$data = [];
if ( $tagsStatus->value ) {
// Specific tags are not allowed.
diff --git a/includes/Rest/Handler/ActionModuleBasedHandler.php b/includes/Rest/Handler/ActionModuleBasedHandler.php
index b4b398cb52b5..ed5d798944a1 100644
--- a/includes/Rest/Handler/ActionModuleBasedHandler.php
+++ b/includes/Rest/Handler/ActionModuleBasedHandler.php
@@ -209,7 +209,7 @@ abstract class ActionModuleBasedHandler extends Handler {
// override to supply mappings
throw new LocalizedHttpException(
- $this->makeMessageValue( $msg ),
+ MessageValue::newFromSpecifier( $msg ),
$statusCode,
// Include the original error code in the response.
// This makes it easier to track down the original cause of the error,
@@ -220,15 +220,4 @@ abstract class ActionModuleBasedHandler extends Handler {
);
}
- /**
- * Constructs a MessageValue from an IApiMessage.
- *
- * @param IApiMessage $msg
- *
- * @return MessageValue
- */
- protected function makeMessageValue( IApiMessage $msg ) {
- return $this->getMessageValueConverter()->convertMessage( $msg );
- }
-
}
diff --git a/includes/Rest/Handler/EditHandler.php b/includes/Rest/Handler/EditHandler.php
index 6f73f12ca8f7..933d0c9a8acb 100644
--- a/includes/Rest/Handler/EditHandler.php
+++ b/includes/Rest/Handler/EditHandler.php
@@ -115,27 +115,27 @@ abstract class EditHandler extends ActionModuleBasedHandler {
$code = $msg->getApiCode();
if ( $code === 'protectedpage' ) {
- throw new LocalizedHttpException( $this->makeMessageValue( $msg ), 403 );
+ throw new LocalizedHttpException( MessageValue::newFromSpecifier( $msg ), 403 );
}
if ( $code === 'badtoken' ) {
- throw new LocalizedHttpException( $this->makeMessageValue( $msg ), 403 );
+ throw new LocalizedHttpException( MessageValue::newFromSpecifier( $msg ), 403 );
}
if ( $code === 'missingtitle' ) {
- throw new LocalizedHttpException( $this->makeMessageValue( $msg ), 404 );
+ throw new LocalizedHttpException( MessageValue::newFromSpecifier( $msg ), 404 );
}
if ( $code === 'articleexists' ) {
- throw new LocalizedHttpException( $this->makeMessageValue( $msg ), 409 );
+ throw new LocalizedHttpException( MessageValue::newFromSpecifier( $msg ), 409 );
}
if ( $code === 'editconflict' ) {
- throw new LocalizedHttpException( $this->makeMessageValue( $msg ), 409 );
+ throw new LocalizedHttpException( MessageValue::newFromSpecifier( $msg ), 409 );
}
if ( $code === 'ratelimited' ) {
- throw new LocalizedHttpException( $this->makeMessageValue( $msg ), 429 );
+ throw new LocalizedHttpException( MessageValue::newFromSpecifier( $msg ), 429 );
}
// Fall through to generic handling of the error (status 400).
diff --git a/includes/Rest/Handler/Helper/RestStatusTrait.php b/includes/Rest/Handler/Helper/RestStatusTrait.php
index 3a0cbc1644e0..ec0257920430 100644
--- a/includes/Rest/Handler/Helper/RestStatusTrait.php
+++ b/includes/Rest/Handler/Helper/RestStatusTrait.php
@@ -3,7 +3,6 @@
namespace MediaWiki\Rest\Handler\Helper;
use MediaWiki\Logger\LoggerFactory;
-use MediaWiki\Message\Converter;
use MediaWiki\Rest\LocalizedHttpException;
use StatusValue;
use Wikimedia\Message\MessageValue;
@@ -13,29 +12,6 @@ use Wikimedia\Message\MessageValue;
*/
trait RestStatusTrait {
- private ?Converter $messageValueConverter = null;
-
- private function getMessageValueConverter(): Converter {
- if ( !$this->messageValueConverter ) {
- $this->messageValueConverter = new Converter();
- }
- return $this->messageValueConverter;
- }
-
- /**
- * Extract the error messages from a Status, as MessageValue objects.
- * @param StatusValue $status
- * @return MessageValue[]
- */
- private function convertStatusToMessageValues( StatusValue $status ): array {
- $conv = $this->getMessageValueConverter();
- return array_map( static function ( $msg ) use ( $conv ) {
- // TODO: It should be possible to do this without going through a Message object,
- // but the internal format of parameters is different in MessageValue (T358779)
- return $conv->convertMessage( $msg );
- }, $status->getMessages() );
- }
-
/**
* @param StatusValue $status
* @param string|MessageValue $msg
@@ -55,9 +31,7 @@ trait RestStatusTrait {
if ( is_string( $msg ) ) {
$msg = MessageValue::new( $msg )
- ->semicolonListParams(
- $this->convertStatusToMessageValues( $status )
- );
+ ->semicolonListParams( $status->getMessages() );
}
throw new LocalizedHttpException( $msg, $code, $data );
diff --git a/includes/Rest/Handler/UpdateHandler.php b/includes/Rest/Handler/UpdateHandler.php
index a61f27446117..3053306fd598 100644
--- a/includes/Rest/Handler/UpdateHandler.php
+++ b/includes/Rest/Handler/UpdateHandler.php
@@ -164,7 +164,7 @@ class UpdateHandler extends EditHandler {
if ( $code === 'editconflict' ) {
$data = $this->getConflictData();
- throw new LocalizedHttpException( $this->makeMessageValue( $msg ), 409, $data );
+ throw new LocalizedHttpException( MessageValue::newFromSpecifier( $msg ), 409, $data );
}
parent::throwHttpExceptionForActionModuleError( $msg, $statusCode );
diff --git a/includes/api/Validator/ApiParamValidator.php b/includes/api/Validator/ApiParamValidator.php
index 40df09b5eb06..8072d2d668ff 100644
--- a/includes/api/Validator/ApiParamValidator.php
+++ b/includes/api/Validator/ApiParamValidator.php
@@ -7,7 +7,6 @@ use MediaWiki\Api\ApiBase;
use MediaWiki\Api\ApiMain;
use MediaWiki\Api\ApiMessage;
use MediaWiki\Api\ApiUsageException;
-use MediaWiki\Message\Converter as MessageConverter;
use MediaWiki\Message\Message;
use MediaWiki\ParamValidator\TypeDef\NamespaceDef;
use MediaWiki\ParamValidator\TypeDef\TagsDef;
@@ -42,9 +41,6 @@ class ApiParamValidator {
/** @var ParamValidator */
private $paramValidator;
- /** @var MessageConverter */
- private $messageConverter;
-
/** Type defs for ParamValidator */
private const TYPE_DEFS = [
'boolean' => [ 'class' => PresenceBooleanDef::class ],
@@ -104,7 +100,6 @@ class ApiParamValidator {
'ismultiLimits' => [ ApiBase::LIMIT_SML1, ApiBase::LIMIT_SML2 ],
]
);
- $this->messageConverter = new MessageConverter();
}
/**
@@ -130,7 +125,7 @@ class ApiParamValidator {
// Convert the message specification to a DataMessageValue. Flag in the data
// that it was so converted, so ApiParamValidatorCallbacks::recordCondition() can
// take that into account.
- $msg = $this->messageConverter->convertMessage( ApiMessage::create( $v ) );
+ $msg = ApiMessage::create( $v );
$v = DataMessageValue::new(
$msg->getKey(),
$msg->getParams(),
@@ -175,7 +170,7 @@ class ApiParamValidator {
private function checkSettingsMessage( ApiBase $module, string $key, $value, array &$ret ): void {
try {
$msg = Message::newFromSpecifier( $value );
- $ret['messages'][] = $this->messageConverter->convertMessage( $msg );
+ $ret['messages'][] = MessageValue::newFromSpecifier( $msg );
} catch ( TimeoutException $e ) {
throw $e;
} catch ( Exception $e ) {
@@ -349,7 +344,7 @@ class ApiParamValidator {
$mv = $ex->getFailureMessage();
throw ApiUsageException::newWithMessage(
$module,
- $this->messageConverter->convertMessageValue( $mv ),
+ $mv,
$mv->getCode(),
$mv->getData(),
0,
@@ -436,7 +431,7 @@ class ApiParamValidator {
$ret = $this->paramValidator->getHelpInfo( $name, $settings, $options );
foreach ( $ret as &$m ) {
$k = $m->getKey();
- $m = $this->messageConverter->convertMessageValue( $m );
+ $m = Message::newFromSpecifier( $m );
if ( str_starts_with( $k, 'paramvalidator-help-' ) ) {
$m = new Message(
[ 'api-help-param-' . substr( $k, 20 ), $k ],
diff --git a/includes/api/Validator/ApiParamValidatorCallbacks.php b/includes/api/Validator/ApiParamValidatorCallbacks.php
index 15915cf05a4f..4aec9fd35be7 100644
--- a/includes/api/Validator/ApiParamValidatorCallbacks.php
+++ b/includes/api/Validator/ApiParamValidatorCallbacks.php
@@ -3,7 +3,6 @@
namespace MediaWiki\Api\Validator;
use MediaWiki\Api\ApiMain;
-use MediaWiki\Message\Converter as MessageConverter;
use Wikimedia\Message\DataMessageValue;
use Wikimedia\ParamValidator\Callbacks;
use Wikimedia\ParamValidator\Util\UploadedFile;
@@ -18,16 +17,12 @@ class ApiParamValidatorCallbacks implements Callbacks {
/** @var ApiMain */
private $apiMain;
- /** @var MessageConverter */
- private $messageConverter;
-
/**
* @internal
* @param ApiMain $main
*/
public function __construct( ApiMain $main ) {
$this->apiMain = $main;
- $this->messageConverter = new MessageConverter();
}
public function hasParam( $name, array $options ) {
@@ -114,7 +109,7 @@ class ApiParamValidatorCallbacks implements Callbacks {
$m = $p;
}
$module->addDeprecation(
- $this->messageConverter->convertMessageValue( $message ),
+ $message,
$feature,
$message->getData()
);
@@ -126,7 +121,7 @@ class ApiParamValidatorCallbacks implements Callbacks {
default:
$module->addWarning(
- $this->messageConverter->convertMessageValue( $message ),
+ $message,
$message->getCode(),
$message->getData()
);
diff --git a/includes/page/RollbackPage.php b/includes/page/RollbackPage.php
index 34cc25511a85..4619f1488dd3 100644
--- a/includes/page/RollbackPage.php
+++ b/includes/page/RollbackPage.php
@@ -27,7 +27,6 @@ use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\HookRunner;
use MediaWiki\Language\RawMessage;
use MediaWiki\MainConfigNames;
-use MediaWiki\Message\Converter;
use MediaWiki\Message\Message;
use MediaWiki\Permissions\Authority;
use MediaWiki\Permissions\PermissionStatus;
@@ -494,8 +493,7 @@ class RollbackPage {
$revisionsBetween,
];
if ( $summary instanceof MessageValue ) {
- $summary = ( new Converter() )->convertMessageValue( $summary );
- $summary = $summary->params( $args )->inContentLanguage()->text();
+ $summary = Message::newFromSpecifier( $summary )->params( $args )->inContentLanguage()->text();
} else {
$summary = ( new RawMessage( $summary, $args ) )->inContentLanguage()->plain();
}
diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php
index a2d133483c90..6264b87e9fd8 100644
--- a/includes/parser/ParserOutput.php
+++ b/includes/parser/ParserOutput.php
@@ -28,7 +28,6 @@ use MediaWiki\Json\JsonDeserializableTrait;
use MediaWiki\Json\JsonDeserializer;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
-use MediaWiki\Message\Converter;
use MediaWiki\Output\OutputPage;
use MediaWiki\Parser\Parsoid\PageBundleParserOutputConverter;
use MediaWiki\Title\TitleValue;
@@ -1096,9 +1095,8 @@ class ParserOutput extends CacheTime implements ContentMetadataCollector {
* @since 1.43
*/
public function addWarningMsgVal( MessageValue $mv ) {
- $m = ( new Converter() )->convertMessageValue( $mv );
- // These can eventually be stored as MessageValue instead of converting to Message.
- $this->addWarningMsg( $m->getKey(), ...$m->getParams() );
+ // These can eventually be stored as MessageValue directly.
+ $this->addWarningMsg( $mv->getKey(), ...$mv->getParams() );
}
/**