From 2de7153afd428f44d1c4c012ffe0bf072e449c64 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 20 Sep 2011 01:39:21 +0200 Subject: [ticket/10345] Allow float as array key and add some tests Added tests for the fallback when a key is missing and the float-feature. PHPBB3-10345 --- phpBB/includes/session.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/session.php') diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 0733e4f7fb..3e3c9dc072 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -1869,7 +1869,7 @@ class user extends session // We now get the first number passed and will select the key based upon this number for ($i = 1, $num_args = sizeof($args); $i < $num_args; $i++) { - if (is_int($args[$i])) + if (is_int($args[$i]) || is_float($args[$i])) { $use_plural_form = $this->get_plural_form($args[$i]); $numbers = array_keys($lang); @@ -1905,12 +1905,14 @@ class user extends session * Determine which plural form we should use. * For some languages this is not as simple as for English. * - * @param $number int The number we want to get the plural case for + * @param $number int|float The number we want to get the plural case for * @param $force_rule mixed False to use the plural rule of the language package * or an integer to force a certain plural rule */ function get_plural_form($number, $force_rule = false) { + $number = (int) $number; + if ($number == 0) { // We use special language strings for 0, so it's "no users" instead of "0 users" -- cgit v1.2.1