mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TitleBlacklist
synced 2024-11-27 15:30:48 +00:00
Show titleblacklist error message in html when using js api module
Parse the message in html according to the errorformat= in the url, fallback to wikitext to avoid a breaking change. Bug: T369244 Change-Id: I58b995b3663b7dd286267e640d8d56164bd9be0b
This commit is contained in:
parent
ea252fcf43
commit
4290e114d4
|
@ -72,7 +72,12 @@ class ApiTitleBlacklist extends ApiBase {
|
|||
$res->addValue( 'titleblacklist', 'result', 'blacklisted' );
|
||||
// there aren't any messages for create(talk|page), using edit for those instead
|
||||
$message = $blacklisted->getErrorMessage( $action !== 'create' ? $action : 'edit' );
|
||||
$res->addValue( 'titleblacklist', 'reason', $this->msg( $message, $result )->page( $title )->text() );
|
||||
$messageObj = $this->msg( $message, $result )->page( $title );
|
||||
if ( $this->getErrorFormatter()->getFormat() === 'html' ) {
|
||||
$res->addValue( 'titleblacklist', 'reason', $messageObj->parse() );
|
||||
} else {
|
||||
$res->addValue( 'titleblacklist', 'reason', $messageObj->text() );
|
||||
}
|
||||
$res->addValue( 'titleblacklist', 'message', $message );
|
||||
$res->addValue( 'titleblacklist', 'line', htmlspecialchars( $blacklisted->getRaw() ) );
|
||||
} else {
|
||||
|
|
|
@ -25,7 +25,11 @@
|
|||
this.get( {
|
||||
action: 'titleblacklist',
|
||||
tbaction: 'create',
|
||||
tbtitle: title.toString()
|
||||
tbtitle: title.toString(),
|
||||
errorformat: 'html',
|
||||
errorlang: mw.config.get( 'wgUserLanguage' ),
|
||||
errorsuselocal: '',
|
||||
formatversion: 2
|
||||
} )
|
||||
.done( function ( data ) {
|
||||
var result;
|
||||
|
|
Loading…
Reference in a new issue