From c1311faebf01db1cd0f27420af31c326b0270d37 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 30 Nov 2011 21:36:56 +0100 Subject: [PATCH] [ticket/10345] Check directly whether the key to use exists PHPBB3-10345 --- phpBB/includes/session.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 401cb0d371..fcbe8aed2c 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -1886,17 +1886,25 @@ class user extends session else { $use_plural_form = $this->get_plural_form($args[$i]); - $numbers = array_keys($lang); - - foreach ($numbers as $num) + if (isset($lang[$use_plural_form])) { - if ($num > $use_plural_form) - { - // If the key we need to use does not exist, we fall back to the previous one. - break; - } + // The key we should use exists, so we use it. + $key_found = $use_plural_form; + } + else + { + // If the key we need to use does not exist, we fall back to the previous one. + $numbers = array_keys($lang); - $key_found = $num; + foreach ($numbers as $num) + { + if ($num > $use_plural_form) + { + break; + } + + $key_found = $num; + } } break; }