X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fapi%2FApiFormatRaw.php;h=ebaeb2ce256ef19713c231af4b5822097769bcb4;hp=9da040ca0b20dbf413ab6d7ef1fc520b3d60dc14;hb=c75f0e95c9888489961548c72ef24786c43838aa;hpb=f56a905990f579a81f15ce636ab03758c15690df diff --git a/includes/api/ApiFormatRaw.php b/includes/api/ApiFormatRaw.php index 9da040ca0b..ebaeb2ce25 100644 --- a/includes/api/ApiFormatRaw.php +++ b/includes/api/ApiFormatRaw.php @@ -49,7 +49,7 @@ class ApiFormatRaw extends ApiFormatBase { public function getMimeType() { $data = $this->getResult()->getResultData(); - if ( isset( $data['error'] ) ) { + if ( isset( $data['error'] ) || isset( $data['errors'] ) ) { return $this->errorFallback->getMimeType(); } @@ -60,9 +60,20 @@ class ApiFormatRaw extends ApiFormatBase { return $data['mime']; } - public function initPrinter( $unused = false ) { + public function getFilename() { $data = $this->getResult()->getResultData(); if ( isset( $data['error'] ) ) { + return $this->errorFallback->getFilename(); + } elseif ( !isset( $data['filename'] ) || $this->getIsWrappedHtml() || $this->getIsHtml() ) { + return parent::getFilename(); + } else { + return $data['filename']; + } + } + + public function initPrinter( $unused = false ) { + $data = $this->getResult()->getResultData(); + if ( isset( $data['error'] ) || isset( $data['errors'] ) ) { $this->errorFallback->initPrinter( $unused ); if ( $this->mFailWithHTTPError ) { $this->getMain()->getRequest()->response()->statusHeader( 400 ); @@ -74,7 +85,7 @@ class ApiFormatRaw extends ApiFormatBase { public function closePrinter() { $data = $this->getResult()->getResultData(); - if ( isset( $data['error'] ) ) { + if ( isset( $data['error'] ) || isset( $data['errors'] ) ) { $this->errorFallback->closePrinter(); } else { parent::closePrinter(); @@ -83,7 +94,7 @@ class ApiFormatRaw extends ApiFormatBase { public function execute() { $data = $this->getResult()->getResultData(); - if ( isset( $data['error'] ) ) { + if ( isset( $data['error'] ) || isset( $data['errors'] ) ) { $this->errorFallback->execute(); return; }