* @param string $warning Warning message
*/
public function setWarning( $warning ) {
+ wfDeprecated( __METHOD__, '1.29' );
$msg = new ApiRawMessage( $warning, 'warning' );
$this->getErrorFormatter()->addWarning( $this->getModulePath(), $msg );
}
* @throws ApiUsageException always
*/
public function dieUsage( $description, $errorCode, $httpRespCode = 0, $extradata = null ) {
+ wfDeprecated( __METHOD__, '1.29' );
$this->dieWithError(
new RawMessage( '$1', [ $description ] ),
$errorCode,
* @throws MWException
*/
public function getErrorFromStatus( $status, &$extraData = null ) {
+ wfDeprecated( __METHOD__, '1.29' );
if ( $status->isGood() ) {
throw new MWException( 'Successful status passed to ApiBase::dieStatus' );
}
* @return [ 'code' => code, 'info' => info ]
*/
public function parseMsg( $error ) {
+ wfDeprecated( __METHOD__, '1.29' );
// Check whether someone passed the whole array, instead of one element as
// documented. This breaks if it's actually an array of fallback keys, but
// that's long-standing misbehavior introduced in r87627 to incorrectly
* @throws ApiUsageException always
*/
public function dieUsageMsg( $error ) {
+ wfDeprecated( __METHOD__, '1.29' );
$this->dieWithError( $this->parseMsgInternal( $error ) );
}
* @since 1.21
*/
public function dieUsageMsgOrDebug( $error ) {
+ wfDeprecated( __METHOD__, '1.29' );
$this->dieWithErrorOrDebug( $this->parseMsgInternal( $error ) );
}
// None of the rest have any messages for non-error types
} elseif ( $e instanceof UsageException ) {
// User entered incorrect parameters - generate error response
- $data = $e->getMessageArray();
+ $data = MediaWiki\quietCall( [ $e, 'getMessageArray' ] );
$code = $data['code'];
$info = $data['info'];
unset( $data['code'], $data['info'] );
$this->mCodestr = $codestr;
$this->mExtraData = $extradata;
+ if ( !$this instanceof ApiUsageException ) {
+ wfDeprecated( __METHOD__, '1.29' );
+ }
+
// This should never happen, so throw an exception about it that will
// hopefully get logged with a backtrace (T138585)
if ( !is_string( $codestr ) || $codestr === '' ) {
* @return string
*/
public function getCodeString() {
+ wfDeprecated( __METHOD__, '1.29' );
return $this->mCodestr;
}
* @return array
*/
public function getMessageArray() {
+ wfDeprecated( __METHOD__, '1.29' );
$result = [
'code' => $this->mCodestr,
'info' => $this->getMessage()
* @inheritdoc
*/
public function getCodeString() {
+ wfDeprecated( __METHOD__, '1.29' );
return $this->getApiMessage()->getApiCode();
}
* @inheritdoc
*/
public function getMessageArray() {
+ wfDeprecated( __METHOD__, '1.29' );
$enMsg = clone $this->getApiMessage();
$enMsg->inLanguage( 'en' )->useDatabase( false );
* @param array $expect
*/
public function testGetMessageFromException( $exception, $options, $expect ) {
+ if ( $exception instanceof UsageException ) {
+ $this->hideDeprecated( 'UsageException::getMessageArray' );
+ }
+
$result = new ApiResult( 8388608 );
$formatter = new ApiErrorFormatter( $result, Language::factory( 'en' ), 'html', false );
}
public static function provideGetMessageFromException() {
+ MediaWiki\suppressWarnings();
+ $usageException = new UsageException(
+ '<b>Something broke!</b>', 'ue-code', 0, [ 'xxx' => 'yyy', 'baz' => 23 ]
+ );
+ MediaWiki\restoreWarnings();
+
return [
'Normal exception' => [
new RuntimeException( '<b>Something broke!</b>' ),
]
],
'UsageException' => [
- new UsageException( '<b>Something broke!</b>', 'ue-code', 0, [ 'xxx' => 'yyy', 'baz' => 23 ] ),
+ $usageException,
[],
[
'text' => '<b>Something broke!</b>',
]
],
'UsageException, wrapped' => [
- new UsageException( '<b>Something broke!</b>', 'ue-code', 0, [ 'xxx' => 'yyy', 'baz' => 23 ] ),
+ $usageException,
[ 'wrap' => 'parentheses', 'code' => 'some-code', 'data' => [ 'foo' => 'bar', 'baz' => 42 ] ],
[
'text' => '(<b>Something broke!</b>)',
MWExceptionHandler::getRedactedTraceAsString( $dbex )
)->inLanguage( 'en' )->useDatabase( false )->text();
+ MediaWiki\suppressWarnings();
+ $usageEx = new UsageException( 'Usage exception!', 'ue', 0, [ 'foo' => 'bar' ] );
+ MediaWiki\restoreWarnings();
+
$apiEx1 = new ApiUsageException( null,
StatusValue::newFatal( new ApiRawMessage( 'An error', 'sv-error1' ) ) );
TestingAccessWrapper::newFromObject( $apiEx1 )->modulePath = 'foo+bar';
]
],
[
- new UsageException( 'Usage exception!', 'ue', 0, [ 'foo' => 'bar' ] ),
+ $usageEx,
[ 'existing-error', 'ue' ],
[
'warnings' => [