/**
* 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
*/
* @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'
}
}
+ Hooks::runWithoutAbort( 'ApiMaxLagInfo', [ &$lagInfo ] );
+
return $lagInfo;
}
*/
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;
$this->setupExternalResponse( $module, $params );
}
- $this->checkAsserts( $params );
-
// Execute
$module->execute();
Hooks::run( 'APIAfterExecute', [ &$module ] );
/**
* 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();