From 9f2be0aeaf535dd0f173354fbc4884aad1fcb508 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Wed, 10 Apr 2019 13:28:34 +0800 Subject: [PATCH] MDL-65275 mod_forum: do not format_text twice() --- mod/forum/classes/local/exporters/post.php | 38 +++++++++++----------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/mod/forum/classes/local/exporters/post.php b/mod/forum/classes/local/exporters/post.php index 73de263d2a2..00716d6a940 100644 --- a/mod/forum/classes/local/exporters/post.php +++ b/mod/forum/classes/local/exporters/post.php @@ -458,6 +458,24 @@ class post extends exporter { ]; } + /** + * This method returns the parameters for the post's message to + * use with the function external_format_text(). + * + * @return array + */ + protected function get_format_parameters_for_message() { + return [ + 'component' => 'mod_forum', + 'filearea' => 'post', + 'itemid' => $this->post->get_id(), + 'options' => [ + 'para' => false, + 'trusted' => $this->post->is_message_trusted() + ] + ]; + } + /** * Get the message text from a post. * @@ -467,15 +485,7 @@ class post extends exporter { private function get_message(post_entity $post) : string { global $CFG; - $context = $this->related['context']; - $message = file_rewrite_pluginfile_urls( - $post->get_message(), - 'pluginfile.php', - $context->id, - 'mod_forum', - 'post', - $post->get_id() - ); + $message = $post->get_message(); if (!empty($CFG->enableplagiarism)) { require_once($CFG->libdir . '/plagiarismlib.php'); @@ -489,16 +499,6 @@ class post extends exporter { ]); } - $message = format_text( - $message, - $post->get_message_format(), - (object) [ - 'para' => false, - 'trusted' => $post->is_message_trusted(), - 'context' => $context - ] - ); - return $message; }