X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiMain.php;h=b398ecd04de0bf8af7117d6d378ea6f5919e5f9a;hb=154e153701d1f3663559ee792f767c0f2b223824;hp=c0c489555dc9e6461cd9246a02a69c2d9bcddead;hpb=7f9d4153d267fc64d3a5161319eb57410df55a9b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index c0c489555d..b398ecd04d 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -165,7 +165,7 @@ class ApiMain extends ApiBase { /** * Constructs an instance of ApiMain that utilizes the module and format specified by $request. * - * @param IContextSource|WebRequest $context If this is an instance of + * @param IContextSource|WebRequest|null $context If this is an instance of * FauxRequest, errors are thrown and no printing occurs * @param bool $enableWrite Should be set to true if the api may modify data */ @@ -486,7 +486,7 @@ class ApiMain extends ApiBase { * @return ApiFormatBase */ public function createPrinterByName( $format ) { - $printer = $this->mModuleMgr->getModule( $format, 'format' ); + $printer = $this->mModuleMgr->getModule( $format, 'format', /* $ignoreCache */ true ); if ( $printer === null ) { $this->dieWithError( [ 'apierror-unknownformat', wfEscapeWikiText( $format ) ], 'unknown_format' @@ -1554,6 +1554,11 @@ class ApiMain extends ApiBase { */ protected function executeAction() { $params = $this->setupExecuteAction(); + + // Check asserts early so e.g. errors in parsing a module's parameters due to being + // logged out don't override the client's intended "am I logged in?" check. + $this->checkAsserts( $params ); + $module = $this->setupModule(); $this->mModule = $module; @@ -1575,8 +1580,6 @@ class ApiMain extends ApiBase { $this->setupExternalResponse( $module, $params ); } - $this->checkAsserts( $params ); - // Execute $module->execute(); Hooks::run( 'APIAfterExecute', [ &$module ] ); @@ -1613,7 +1616,7 @@ class ApiMain extends ApiBase { /** * Log the preceding request * @param float $time Time in seconds - * @param Exception $e Exception caught while processing the request + * @param Exception|null $e Exception caught while processing the request */ protected function logRequest( $time, $e = null ) { $request = $this->getRequest();