From 7089931743374295ce7a5165ad0c1f794a19536d Mon Sep 17 00:00:00 2001 From: skodak Date: Mon, 1 Sep 2008 14:54:57 +0000 Subject: [PATCH] MDL-16292 print_error not backwards compatible with error(get_string('xx', 'moodle')); merged from MOODLE_19_STABLE --- lib/weblib.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index 5248d32103..0f6ca41bdd 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -5548,7 +5548,7 @@ function print_scale_menu_helpbutton($courseid, $scale, $return=false) { * @param object $a Extra words and phrases that might be required in the error string * @return terminates script, does not return! */ -function print_error($errorcode, $module='', $link='', $a=NULL) { +function print_error($errorcode, $module='error', $link='', $a=NULL) { global $CFG, $UNITTEST; // If unittest running, throw exception instead @@ -5581,13 +5581,17 @@ function _print_normal_error($errorcode, $module, $a, $link, $backtrace, $debugi $DB->set_debug(0); } - if ($module == 'error') { + if ($module === 'error') { $modulelink = 'moodle'; } else { $modulelink = $module; } $message = get_string($errorcode, $module, $a); + if ($module === 'error' and strpos($message, '[[') === 0) { + //search in moodle file if error specified - needed for backwards compatibility + $message = get_string($errorcode, 'moodle', $a); + } if (defined('FULLME') && FULLME == 'cron') { // Errors in cron should be mtrace'd. @@ -5664,7 +5668,12 @@ function _print_normal_error($errorcode, $module, $a, $link, $backtrace, $debugi * This function is used if fatal error occures before the themes are fully initialised (eg. in lib/setup.php) */ function _print_early_error($errorcode, $module, $a) { - $message = clean_text(get_string($errorcode, $module, $a)); + $message = get_string($errorcode, $module, $a); + if ($module === 'error' and strpos($message, '[[') === 0) { + //search in moodle file if error specified - needed for backwards compatibility + $message = get_string($errorcode, 'moodle', $a); + } + $message = clean_text($message); // In the name of protocol correctness, monitoring and performance // profiling, set the appropriate error headers for machine comsumption -- 2.39.5