mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 16:44:51 +00:00
Merge "ApiVisualEditorEdit: Make tryDeflate public and static"
This commit is contained in:
commit
a53971681f
|
@ -118,14 +118,19 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
|
|||
];
|
||||
}
|
||||
|
||||
protected function tryDeflate( $content ) {
|
||||
public static function tryDeflate( $content ) {
|
||||
if ( substr( $content, 0, 11 ) === 'rawdeflate,' ) {
|
||||
$deflated = base64_decode( substr( $content, 11 ) );
|
||||
MediaWiki\suppressWarnings();
|
||||
$inflated = gzinflate( $deflated );
|
||||
MediaWiki\restoreWarnings();
|
||||
if ( $deflated === $inflated || $inflated === false ) {
|
||||
$this->dieWithError( 'apierror-visualeditor-invaliddeflate', 'invaliddeflate' );
|
||||
// Static equivalent of $this->dieWithError
|
||||
throw ApiUsageException::newWithMessage(
|
||||
null,
|
||||
'apierror-visualeditor-invaliddeflate',
|
||||
'invaliddeflate'
|
||||
);
|
||||
}
|
||||
return $inflated;
|
||||
}
|
||||
|
@ -147,7 +152,7 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
|
|||
protected function getWikitextNoCache( $title, $params, $parserParams ) {
|
||||
$this->requireOnlyOneParameter( $params, 'html' );
|
||||
$wikitext = $this->postHTML(
|
||||
$title, $this->tryDeflate( $params['html'] ), $parserParams, $params['etag']
|
||||
$title, self::tryDeflate( $params['html'] ), $parserParams, $params['etag']
|
||||
);
|
||||
if ( $wikitext === false ) {
|
||||
$this->dieWithError( 'apierror-visualeditor-docserver', 'docserver' );
|
||||
|
|
Loading…
Reference in a new issue