X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiHelp.php;h=2627715d5a41204907071af4143997119bb36ade;hb=320ec708e4b887a41f1532797cf1a114d240df4b;hp=988957b6d8723a46bff48c849d09a8b7accd4edc;hpb=f585244a778ed712859f48383472c24f105b1b4e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiHelp.php b/includes/api/ApiHelp.php index 988957b6d8..2627715d5a 100644 --- a/includes/api/ApiHelp.php +++ b/includes/api/ApiHelp.php @@ -66,6 +66,23 @@ class ApiHelp extends ApiBase { ApiResult::setSubelementsList( $data, 'help' ); $result->addValue( null, $this->getModuleName(), $data ); } else { + // Show any errors at the top of the HTML + $transform = [ + 'Types' => [ 'AssocAsObject' => true ], + 'Strip' => 'all', + ]; + $errors = array_filter( [ + 'errors' => $this->getResult()->getResultData( [ 'errors' ], $transform ), + 'warnings' => $this->getResult()->getResultData( [ 'warnings' ], $transform ), + ] ); + if ( $errors ) { + $json = FormatJson::encode( $errors, true, FormatJson::UTF8_OK ); + // Escape any "--", some parsers might interpret that as end-of-comment. + // The above already escaped any "<" and ">". + $json = str_replace( '--', '-\u002D', $json ); + $html = "\n$html"; + } + $result->reset(); $result->addValue( null, 'text', $html, ApiResult::NO_SIZE_CHECK ); $result->addValue( null, 'mime', 'text/html', ApiResult::NO_SIZE_CHECK );