* 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;
}
$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
// 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();
}
if ( !isset( $moduleParams['token'] ) ) {
+ // Probably can't happen
+ // @codeCoverageIgnoreStart
$module->dieWithError( [ 'apierror-missingparam', 'token' ] );
+ // @codeCoverageIgnoreEnd
}
$module->requirePostedParameters( [ 'token' ] );
}
// Allow extensions to stop execution for arbitrary reasons.
- $message = false;
+ $message = 'hookaborted';
if ( !Hooks::run( 'ApiCheckCanExecute', [ $module, $user, &$message ] ) ) {
$this->dieWithError( $message );
}
/**
* 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;