X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiBase.php;h=ac07eebe3b0dafd7bb623219497f88996da2094c;hb=90d4f56fe46140f9e97e2fa72698f98b57447fe5;hp=8a99e6a97fd8938ad43bee95c314d143e40c5893;hpb=a93cf8f4eee40a448bcd99b8fe1c32dc80775b6b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 8a99e6a97f..ac07eebe3b 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -1100,7 +1100,7 @@ abstract class ApiBase extends ContextSource { * Return true if we're to watch the page, false if not, null if no change. * @param string $watchlist Valid values: 'watch', 'unwatch', 'preferences', 'nochange' * @param Title $titleObj The page under consideration - * @param string $userOption The user option to consider when $watchlist=preferences. + * @param string|null $userOption The user option to consider when $watchlist=preferences. * If not set will use watchdefault always and watchcreations if $titleObj doesn't exist. * @return bool */ @@ -1246,8 +1246,8 @@ abstract class ApiBase extends ContextSource { // Preserve U+001F for self::parseMultiValue(), or error out if that won't be called if ( isset( $value ) && substr( $rawValue, 0, 1 ) === "\x1f" ) { if ( $multi ) { - // This loses the potential $wgContLang->checkTitleEncoding() transformation - // done by WebRequest for $_GET. Let's call that a feature. + // This loses the potential checkTitleEncoding() transformation done by + // WebRequest for $_GET. Let's call that a feature. $value = implode( "\x1f", $request->normalizeUnicode( explode( "\x1f", $rawValue ) ) ); } else { $this->dieWithError( 'apierror-badvalue-notmultivalue', 'badvalue_notmultivalue' ); @@ -1289,7 +1289,7 @@ abstract class ApiBase extends ContextSource { case 'text': case 'password': if ( $required && $value === '' ) { - $this->dieWithError( [ 'apierror-missingparam', $paramName ] ); + $this->dieWithError( [ 'apierror-missingparam', $encParamName ] ); } break; case 'integer': // Force everything using intval() and optionally validate limits @@ -1443,7 +1443,7 @@ abstract class ApiBase extends ContextSource { } } } elseif ( $required ) { - $this->dieWithError( [ 'apierror-missingparam', $paramName ] ); + $this->dieWithError( [ 'apierror-missingparam', $encParamName ] ); } return $value; @@ -1574,7 +1574,7 @@ abstract class ApiBase extends ContextSource { * @param int &$value Parameter value * @param int|null $min Minimum value * @param int|null $max Maximum value for users - * @param int $botMax Maximum value for sysops/bots + * @param int|null $botMax Maximum value for sysops/bots * @param bool $enforceLimits Whether to enforce (die) if value is outside limits */ protected function validateLimit( $paramName, &$value, $min, $max, $botMax = null, @@ -1744,7 +1744,7 @@ abstract class ApiBase extends ContextSource { * Set a watch (or unwatch) based the based on a watchlist parameter. * @param string $watch Valid values: 'watch', 'unwatch', 'preferences', 'nochange' * @param Title $titleObj The article's title to change - * @param string $userOption The user option to consider when $watch=preferences + * @param string|null $userOption The user option to consider when $watch=preferences */ protected function setWatch( $watch, $titleObj, $userOption = null ) { $value = $this->getWatchlistValue( $watch, $titleObj, $userOption ); @@ -1812,14 +1812,14 @@ abstract class ApiBase extends ContextSource { * @since 1.25 * @param string|array|Message $msg * @param IContextSource $context - * @param array $params + * @param array|null $params * @return Message|null */ public static function makeMessage( $msg, IContextSource $context, array $params = null ) { if ( is_string( $msg ) ) { $msg = wfMessage( $msg ); } elseif ( is_array( $msg ) ) { - $msg = call_user_func_array( 'wfMessage', $msg ); + $msg = wfMessage( ...$msg ); } if ( !$msg instanceof Message ) { return null; @@ -1866,7 +1866,7 @@ abstract class ApiBase extends ContextSource { [ 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $user->getBlock() ) ] ) ); } else { - call_user_func_array( [ $status, 'fatal' ], (array)$error ); + $status->fatal( ...(array)$error ); } } return $status; @@ -2045,10 +2045,7 @@ abstract class ApiBase extends ContextSource { if ( !$status->getErrorsByType( 'error' ) ) { $newStatus = Status::newGood(); foreach ( $status->getErrorsByType( 'warning' ) as $err ) { - call_user_func_array( - [ $newStatus, 'fatal' ], - array_merge( [ $err['message'] ], $err['params'] ) - ); + $newStatus->fatal( $err['message'], ...$err['params'] ); } if ( !$newStatus->getErrorsByType( 'error' ) ) { $newStatus->fatal( 'unknownerror-nocode' ); @@ -2085,7 +2082,7 @@ abstract class ApiBase extends ContextSource { $user = $this->getUser(); } $rights = (array)$rights; - if ( !call_user_func_array( [ $user, 'isAllowedAny' ], $rights ) ) { + if ( !$user->isAllowedAny( ...$rights ) ) { $this->dieWithError( [ 'apierror-permissiondenied', $this->msg( "action-{$rights[0]}" ) ] ); } } @@ -2678,16 +2675,14 @@ abstract class ApiBase extends ContextSource { * @deprecated since 1.25 */ public function profileIn() { - // No wfDeprecated() yet because extensions call this and might need to - // keep doing so for BC. + wfDeprecated( __METHOD__, '1.25' ); } /** * @deprecated since 1.25 */ public function profileOut() { - // No wfDeprecated() yet because extensions call this and might need to - // keep doing so for BC. + wfDeprecated( __METHOD__, '1.25' ); } /**