X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiMain.php;h=b7b13c5dfcf1642487014a399bfa110d1d0283fa;hb=4660ce079ca78a66e4ec7386481868a52ecebda5;hp=2c2dd9ab23f6add16856484b6eafa8d6eadd9e24;hpb=801c6810a741cffed1174267958bd3426fd1d191;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 2c2dd9ab23..b7b13c5dfc 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -368,19 +368,12 @@ class ApiMain extends ApiBase { * Set the continuation manager * @param ApiContinuationManager|null $manager */ - public function setContinuationManager( $manager ) { - if ( $manager !== null ) { - if ( !$manager instanceof ApiContinuationManager ) { - throw new InvalidArgumentException( __METHOD__ . ': Was passed ' . - is_object( $manager ) ? get_class( $manager ) : gettype( $manager ) - ); - } - if ( $this->mContinuationManager !== null ) { - throw new UnexpectedValueException( - __METHOD__ . ': tried to set manager from ' . $manager->getSource() . - ' when a manager is already set from ' . $this->mContinuationManager->getSource() - ); - } + public function setContinuationManager( ApiContinuationManager $manager = null ) { + if ( $manager !== null && $this->mContinuationManager !== null ) { + throw new UnexpectedValueException( + __METHOD__ . ': tried to set manager from ' . $manager->getSource() . + ' when a manager is already set from ' . $this->mContinuationManager->getSource() + ); } $this->mContinuationManager = $manager; } @@ -593,7 +586,7 @@ class ApiMain extends ApiBase { $this->setCacheMode( 'private' ); $response = $this->getRequest()->response(); - $headerStr = 'MediaWiki-API-Error: ' . join( ', ', $errCodes ); + $headerStr = 'MediaWiki-API-Error: ' . implode( ', ', $errCodes ); $response->header( $headerStr ); // Reset and print just the error message @@ -1037,7 +1030,7 @@ class ApiMain extends ApiBase { // None of the rest have any messages for non-error types } elseif ( $e instanceof UsageException ) { // User entered incorrect parameters - generate error response - $data = MediaWiki\quietCall( [ $e, 'getMessageArray' ] ); + $data = Wikimedia\quietCall( [ $e, 'getMessageArray' ] ); $code = $data['code']; $info = $data['info']; unset( $data['code'], $data['info'] ); @@ -1199,9 +1192,12 @@ class ApiMain extends ApiBase { // Instantiate the module requested by the user $module = $this->mModuleMgr->getModule( $this->mAction, 'action' ); if ( $module === null ) { + // Probably can't happen + // @codeCoverageIgnoreStart $this->dieWithError( [ 'apierror-unknownaction', wfEscapeWikiText( $this->mAction ) ], 'unknown_action' ); + // @codeCoverageIgnoreEnd } $moduleParams = $module->extractRequestParams(); @@ -1220,7 +1216,10 @@ class ApiMain extends ApiBase { } if ( !isset( $moduleParams['token'] ) ) { + // Probably can't happen + // @codeCoverageIgnoreStart $module->dieWithError( [ 'apierror-missingparam', 'token' ] ); + // @codeCoverageIgnoreEnd } $module->requirePostedParameters( [ 'token' ] ); @@ -1397,9 +1396,9 @@ class ApiMain extends ApiBase { $this->getRequest()->response()->statusHeader( 304 ); // Avoid outputting the compressed representation of a zero-length body - MediaWiki\suppressWarnings(); + Wikimedia\suppressWarnings(); ini_set( 'zlib.output_compression', 0 ); - MediaWiki\restoreWarnings(); + Wikimedia\restoreWarnings(); wfClearOutputBuffers(); return false; @@ -1433,7 +1432,7 @@ class ApiMain extends ApiBase { } // Allow extensions to stop execution for arbitrary reasons. - $message = false; + $message = 'hookaborted'; if ( !Hooks::run( 'ApiCheckCanExecute', [ $module, $user, &$message ] ) ) { $this->dieWithError( $message ); } @@ -1720,8 +1719,8 @@ class ApiMain extends ApiBase { /** * Get a request value, and register the fact that it was used, for logging. * @param string $name - * @param mixed $default - * @return mixed + * @param string|null $default + * @return string|null */ public function getVal( $name, $default = null ) { $this->mParamsUsed[$name] = true;