Index: moodlelib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/moodlelib.php,v retrieving revision 1.960.2.81 diff -u -r1.960.2.81 moodlelib.php --- moodlelib.php 6 Jul 2008 22:54:06 -0000 1.960.2.81 +++ moodlelib.php 7 Jul 2008 15:52:36 -0000 @@ -5566,20 +5566,27 @@ /** * Returns a list of country names in the current language * + * There are three possible locations of the list to use: 1) current language, 2) parent language, 3) en_utf8. + * The function uses an attempt counter to pick the lang pack containing the list. Please note, + * simple checking of the countries.php existence is not enough as the file might be empty (MDL-12465). + * + * @param int $attempt The first (default), second or third attempt to get the list * @uses $CFG * @uses $USER * @return array */ -function get_list_of_countries() { +function get_list_of_countries($attempt=1) { global $CFG, $USER; $lang = current_language(); - if (!file_exists($CFG->dirroot .'/lang/'. $lang .'/countries.php') && - !file_exists($CFG->dataroot.'/lang/'. $lang .'/countries.php')) { + if ($attempt > 1 || + (!file_exists($CFG->dirroot .'/lang/'. $lang .'/countries.php') && + !file_exists($CFG->dataroot.'/lang/'. $lang .'/countries.php'))) { if ($parentlang = get_string('parentlanguage')) { - if (file_exists($CFG->dirroot .'/lang/'. $parentlang .'/countries.php') || - file_exists($CFG->dataroot.'/lang/'. $parentlang .'/countries.php')) { + if (($attempt == 2) && + (file_exists($CFG->dirroot .'/lang/'. $parentlang .'/countries.php') || + file_exists($CFG->dataroot.'/lang/'. $parentlang .'/countries.php'))) { $lang = $parentlang; } else { $lang = 'en_utf8'; // countries.php must exist in this pack @@ -5748,6 +5755,8 @@ if (!empty($string)) { asort($string); + } else if ($attempt < 3) { + return get_list_of_countries($attempt+1); } return $string;