X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fapi%2FApiCSPReport.php;h=4139019ccf0a4d73faa94f03473c2e8730fa797a;hp=5a0edfcd82ddc9cedecd82d0ee9f39bd3eee0c1b;hb=ce079cf6ad79ca8d3360817f809b219d166f9153;hpb=864be4b56ebc2ad3a80d775aae6e11d14f06ed65 diff --git a/includes/api/ApiCSPReport.php b/includes/api/ApiCSPReport.php index 5a0edfcd82..4139019ccf 100644 --- a/includes/api/ApiCSPReport.php +++ b/includes/api/ApiCSPReport.php @@ -137,8 +137,11 @@ class ApiCSPReport extends ApiBase { } $status = FormatJson::parse( $postBody, FormatJson::FORCE_ASSOC ); if ( !$status->isGood() ) { - list( $code, ) = $this->getErrorFromStatus( $status ); - $this->error( $code, __METHOD__ ); + $msg = $status->getErrors()[0]['message']; + if ( $msg instanceof Message ) { + $msg = $msg->getKey(); + } + $this->error( $msg, __METHOD__ ); } $report = $status->getValue(); @@ -176,7 +179,7 @@ class ApiCSPReport extends ApiBase { * * @param $code String error code * @param $method String method that made error - * @throws UsageException Always + * @throws ApiUsageException Always */ private function error( $code, $method ) { $this->log->info( 'Error reading CSP report: ' . $code, [ @@ -184,7 +187,9 @@ class ApiCSPReport extends ApiBase { 'user-agent' => $this->getRequest()->getHeader( 'user-agent' ) ] ); // 500 so it shows up in browser's developer console. - $this->dieUsage( "Error processing CSP report: $code", 'cspreport-' . $code, 500 ); + $this->dieWithError( + [ 'apierror-csp-report', wfEscapeWikiText( $code ) ], 'cspreport-' . $code, [], 500 + ); } public function getAllowedParams() {