From f34c1fcee69945a8da23b1c53f4140dab4d03d0f Mon Sep 17 00:00:00 2001 From: GOLEM Date: Tue, 20 Aug 2019 00:41:47 +0200 Subject: [PATCH] Patch for rest api --- MathRestbaseInterface.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/MathRestbaseInterface.php b/MathRestbaseInterface.php index 2dc5d45..b89a7f0 100644 --- a/MathRestbaseInterface.php +++ b/MathRestbaseInterface.php @@ -8,6 +8,8 @@ use MediaWiki\Logger\LoggerFactory; +const WikiMediaServersReturnInvalidErrorCodes = true; + class MathRestbaseInterface { private $hash = false; private $tex; @@ -364,7 +366,7 @@ class MathRestbaseInterface { */ public function evaluateRestbaseCheckResponse( $response ) { $json = json_decode( $response['body'] ); - if ( $response['code'] === 200 ) { + if ( $response['code'] === 200 || WikiMediaServersReturnInvalidErrorCodes ) { $headers = $response['headers']; $this->hash = $headers['x-resource-location']; $this->success = $json->success; @@ -418,7 +420,7 @@ class MathRestbaseInterface { * @throws MWException */ private function evaluateContentResponse( $type, $response, $request ) { - if ( $response['code'] === 200 ) { + if ( $response['code'] === 200 || WikiMediaServersReturnInvalidErrorCodes ) { if ( array_key_exists( 'x-mathoid-style', $response['headers'] ) ) { $this->mathoidStyle = $response['headers']['x-mathoid-style']; } @@ -453,3 +455,4 @@ class MathRestbaseInterface { throw new MWException( "Cannot get $type. $detail" ); } } +