Replace uses of deprecated MediaWiki\Message\Converter

The converter is no longer needed now that Message and MessageValue
use the same internal format for the message parameters.

Depends-On: I625a48a6ecd3fad5c2ed76b23343a0fef91e1b83
Change-Id: I9f27d7e31be144e09ed3d0e0e858433477327b00
This commit is contained in:
Bartosz Dziewoński 2024-10-21 19:31:16 +02:00
parent f834094206
commit d08df5302b

View file

@ -14,7 +14,6 @@ use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
use MediaWiki\Api\ApiUsageException;
use MediaWiki\Language\Language;
use MediaWiki\MediaWikiServices;
use MediaWiki\Message\Message;
use MediaWiki\Request\WebRequest;
use MediaWiki\Rest\HttpException;
use MediaWiki\Rest\LocalizedHttpException;
@ -23,6 +22,7 @@ use MediaWiki\Title\Title;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Throwable;
use Wikimedia\Message\MessageSpecifier;
use Wikimedia\Stats\NullStatsdDataFactory;
use Wikimedia\Stats\PrefixingStatsdDataFactoryProxy;
@ -69,9 +69,7 @@ trait ApiParsoidTrait {
*/
private function dieWithRestHttpException( HttpException $ex ): void {
if ( $ex instanceof LocalizedHttpException ) {
$converter = new \MediaWiki\Message\Converter();
$msg = $converter->convertMessageValue( $ex->getMessageValue() );
$this->dieWithError( $msg, null, $ex->getErrorData() );
$this->dieWithError( $ex->getMessageValue(), null, $ex->getErrorData() );
} else {
$this->dieWithException( $ex, [ 'data' => $ex->getErrorData() ] );
}
@ -186,19 +184,20 @@ trait ApiParsoidTrait {
/**
* @see ApiBase
* @param string|array|Message $msg See ApiErrorFormatter::addError()
* @param string|array|MessageSpecifier $msg See ApiErrorFormatter::addError()
* @param string|null $code See ApiErrorFormatter::addError()
* @param array|null $data See ApiErrorFormatter::addError()
* @param int|null $httpCode HTTP error code to use
* @param int $httpCode HTTP error code to use
* @throws ApiUsageException always
* @return never
* @throws ApiUsageException
*/
abstract public function dieWithError( $msg, $code = null, $data = null, $httpCode = null );
abstract public function dieWithError( $msg, $code = null, $data = null, $httpCode = 0 );
/**
* @see ApiBase
* @param Throwable $exception See ApiErrorFormatter::getMessageFromException()
* @param array $options See ApiErrorFormatter::getMessageFromException()
* @throws ApiUsageException always
* @return never
*/
abstract public function dieWithException( Throwable $exception, array $options = [] );