X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FMessage.php;h=fd67613e28d2ab7faf73d5e3866ff48fcf20c4bf;hb=4fc7420feaeb082b741c45503fb8449a882adedd;hp=7e5cc7dca23b71f9e1d44192d9fdd3b8a930f8af;hpb=19bc3e4966b9f27a71eda0f65f44e6d20d244658;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Message.php b/includes/Message.php index 7e5cc7dca2..fd67613e28 100644 --- a/includes/Message.php +++ b/includes/Message.php @@ -488,18 +488,32 @@ class Message implements MessageSpecifier, Serializable { * * @since 1.17 * - * @param mixed ... Parameters as strings, or a single argument that is - * an array of strings. + * @param mixed ... Parameters as strings or arrays from + * Message::numParam() and the like, or a single array of parameters. * * @return Message $this */ public function params( /*...*/ ) { $args = func_get_args(); - if ( isset( $args[0] ) && is_array( $args[0] ) ) { - $args = $args[0]; + + // If $args has only one entry and it's an array, then it's either a + // non-varargs call or it happens to be a call with just a single + // "special" parameter. Since the "special" parameters don't have any + // numeric keys, we'll test that to differentiate the cases. + if ( count( $args ) === 1 && isset( $args[0] ) && is_array( $args[0] ) ) { + if ( $args[0] === [] ) { + $args = []; + } else { + foreach ( $args[0] as $key => $value ) { + if ( is_int( $key ) ) { + $args = $args[0]; + break; + } + } + } } - $args_values = array_values( $args ); - $this->parameters = array_merge( $this->parameters, $args_values ); + + $this->parameters = array_merge( $this->parameters, array_values( $args ) ); return $this; } @@ -1040,9 +1054,9 @@ class Message implements MessageSpecifier, Serializable { /** * @since 1.22 * - * @param number $period + * @param int $period * - * @return number[] Array with a single "period" key. + * @return int[] Array with a single "period" key. */ public static function timeperiodParam( $period ) { return [ 'period' => $period ]; @@ -1291,8 +1305,9 @@ class Message implements MessageSpecifier, Serializable { */ protected function formatListParam( array $params, $listType, $format ) { if ( !isset( self::$listTypeMap[$listType] ) ) { - $warning = 'Invalid list type for message "' . $this->getKey() . '": ' . - htmlspecialchars( serialize( $param ) ); + $warning = 'Invalid list type for message "' . $this->getKey() . '": ' + . htmlspecialchars( $listType ) + . ' (params are ' . htmlspecialchars( serialize( $params ) ) . ')'; trigger_error( $warning, E_USER_WARNING ); $e = new Exception; wfDebugLog( 'Bug58676', $warning . "\n" . $e->getTraceAsString() );