From: skodak Date: Tue, 24 Oct 2006 22:19:41 +0000 (+0000) Subject: Strip ##TRUSTTEXT## when not in developer debug mode MDL-7190; minor format_text... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=d53ca6ad4027ea2086163d57d99fe42f9792025f;p=moodle.git Strip ##TRUSTTEXT## when not in developer debug mode MDL-7190; minor format_text speedup; changed in md5 text cache calculation; merged from MOODLE_17_STABLE --- diff --git a/lib/weblib.php b/lib/weblib.php index 90f022db15..5096446403 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -1256,6 +1256,10 @@ function format_text($text, $format=FORMAT_MOODLE, $options=NULL, $courseid=NULL global $CFG, $course; + if ($text === '') { + return ''; // no need to do any filters and cleaning + } + if (!isset($options->trusttext)) { $options->trusttext = false; } @@ -1287,7 +1291,7 @@ function format_text($text, $format=FORMAT_MOODLE, $options=NULL, $courseid=NULL if (!empty($CFG->cachetext) and empty($options->nocache)) { $time = time() - $CFG->cachetext; - $md5key = md5($text.'-'.$courseid.$options->noclean.$options->smiley.$options->filter.$options->para.$options->newlines.$format.current_language().$courseid.$options->trusttext); + $md5key = md5($text.'-'.(int)$courseid.'-'.current_language().'-'.(int)$format.(int)$options->trusttext).(int)$options->noclean.(int)$options->smiley.(int)$options->filter.(int)$options->para.(int)$options->newlines; if ($oldcacheitem = get_record_sql('SELECT * FROM '.$CFG->prefix.'cache_text WHERE md5key = \''.$md5key.'\'', true)) { if ($oldcacheitem->timemodified >= $time) { return $oldcacheitem->formattedtext; @@ -1307,6 +1311,10 @@ function format_text($text, $format=FORMAT_MOODLE, $options=NULL, $courseid=NULL } else { $options->noclean = false; } + } else if (!debugging('', DEBUG_DEVELOPER)) { + // strip any forgotten trusttext in non-developer mode + // do not forget to disable text cache when debugging trusttext!! + $text = trusttext_strip($text); } $CFG->currenttextiscacheable = true; // Default status - can be changed by any filter