From 0d851f90a8d2c6537c781c822621c335fb8359a7 Mon Sep 17 00:00:00 2001 From: moodler Date: Wed, 11 Feb 2004 02:26:25 +0000 Subject: [PATCH] Cache format_text calls in make_mail_post for even more speed during a forum_cron --- mod/forum/lib.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mod/forum/lib.php b/mod/forum/lib.php index b46f6479b5..3c4ea725fe 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -1078,6 +1078,14 @@ function forum_make_mail_post(&$post, $user, $touser, $course, global $THEME, $CFG; + static $formattedtext; // Cached version of formatted text for a post + static $formattedtextid; // The ID number of the post + + if (empty($formattedtextid) or $formattedtextid != $post->id) { // Recalculate the formatting + $formattedtext = format_text($post->message, $post->format, NULL, $course->id); + $formattedtextid = $post->id; + } + $output = ""; $output .= "