X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiBase.php;h=4898385cfc12e7db63294d9f558f274db99d25fb;hb=4691389fa46f79cbeaf2daffda407cf7daa66fd4;hp=1d209fdb09ef421a38681b0fc1a8bc80a45e095a;hpb=960fdcd86c3d7bbdd661ccd5a2a4086fb9be0a94;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 1d209fdb09..4898385cfc 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -1282,7 +1282,7 @@ abstract class ApiBase extends ContextSource { } } } else { - $value = intval( $value ); + $value = (int)$value; if ( !is_null( $min ) || !is_null( $max ) ) { $this->validateLimit( $paramName, $value, $min, $max, null, $enforceLimits ); } @@ -1311,7 +1311,7 @@ abstract class ApiBase extends ContextSource { : $paramSettings[self::PARAM_MAX]; $this->getResult()->addParsedLimit( $this->getModuleName(), $value ); } else { - $value = intval( $value ); + $value = (int)$value; $this->validateLimit( $paramName, $value, @@ -2112,15 +2112,21 @@ abstract class ApiBase extends ContextSource { /** * Helper function for permission-denied errors * @since 1.29 + * @since 1.33 Changed the third parameter from $user to $options. * @param Title $title * @param string|string[] $actions - * @param User|null $user + * @param array $options Additional options + * - user: (User) User to use rather than $this->getUser() + * - autoblock: (bool, default false) Whether to spread autoblocks + * For compatibility, passing a User object is treated as the value for the 'user' option. * @throws ApiUsageException if the user doesn't have all of the rights. */ - public function checkTitleUserPermissions( Title $title, $actions, $user = null ) { - if ( !$user ) { - $user = $this->getUser(); + public function checkTitleUserPermissions( Title $title, $actions, $options = [] ) { + if ( !is_array( $options ) ) { + wfDeprecated( '$user as the third parameter to ' . __METHOD__, '1.33' ); + $options = [ 'user' => $options ]; } + $user = $options['user'] ?? $this->getUser(); $errors = []; foreach ( (array)$actions as $action ) { @@ -2133,6 +2139,10 @@ abstract class ApiBase extends ContextSource { $this->trackBlockNotices( $errors ); } + if ( !empty( $options['autoblock'] ) ) { + $user->spreadAnyEditBlock(); + } + $this->dieStatus( $this->errorArrayToStatus( $errors, $user ) ); } }