Merge "ApiVisualEditorEdit: Make tryDeflate public and static"

This commit is contained in:
jenkins-bot 2017-09-14 22:00:27 +00:00 committed by Gerrit Code Review
commit a53971681f

View file

@ -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' );