Patch for rest api
This commit is contained in:
parent
a1263dbe1f
commit
f34c1fcee6
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
use MediaWiki\Logger\LoggerFactory;
|
use MediaWiki\Logger\LoggerFactory;
|
||||||
|
|
||||||
|
const WikiMediaServersReturnInvalidErrorCodes = true;
|
||||||
|
|
||||||
class MathRestbaseInterface {
|
class MathRestbaseInterface {
|
||||||
private $hash = false;
|
private $hash = false;
|
||||||
private $tex;
|
private $tex;
|
||||||
|
@ -364,7 +366,7 @@ class MathRestbaseInterface {
|
||||||
*/
|
*/
|
||||||
public function evaluateRestbaseCheckResponse( $response ) {
|
public function evaluateRestbaseCheckResponse( $response ) {
|
||||||
$json = json_decode( $response['body'] );
|
$json = json_decode( $response['body'] );
|
||||||
if ( $response['code'] === 200 ) {
|
if ( $response['code'] === 200 || WikiMediaServersReturnInvalidErrorCodes ) {
|
||||||
$headers = $response['headers'];
|
$headers = $response['headers'];
|
||||||
$this->hash = $headers['x-resource-location'];
|
$this->hash = $headers['x-resource-location'];
|
||||||
$this->success = $json->success;
|
$this->success = $json->success;
|
||||||
|
@ -418,7 +420,7 @@ class MathRestbaseInterface {
|
||||||
* @throws MWException
|
* @throws MWException
|
||||||
*/
|
*/
|
||||||
private function evaluateContentResponse( $type, $response, $request ) {
|
private function evaluateContentResponse( $type, $response, $request ) {
|
||||||
if ( $response['code'] === 200 ) {
|
if ( $response['code'] === 200 || WikiMediaServersReturnInvalidErrorCodes ) {
|
||||||
if ( array_key_exists( 'x-mathoid-style', $response['headers'] ) ) {
|
if ( array_key_exists( 'x-mathoid-style', $response['headers'] ) ) {
|
||||||
$this->mathoidStyle = $response['headers']['x-mathoid-style'];
|
$this->mathoidStyle = $response['headers']['x-mathoid-style'];
|
||||||
}
|
}
|
||||||
|
@ -453,3 +455,4 @@ class MathRestbaseInterface {
|
||||||
throw new MWException( "Cannot get $type. $detail" );
|
throw new MWException( "Cannot get $type. $detail" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue