MDL-65468 forum: Check if passed form data is empty
authorMihail Geshoski <mihail@moodle.com>
Thu, 2 May 2019 08:22:00 +0000 (16:22 +0800)
committerMihail Geshoski <mihail@moodle.com>
Thu, 2 May 2019 08:22:00 +0000 (16:22 +0800)
mod/forum/post.php

index 375559c..1fb68f3 100644 (file)
@@ -768,14 +768,14 @@ if ($mformpost->is_cancelled()) {
     } else {
         redirect($urlfactory->get_discussion_view_url_from_discussion($discussionentity));
     }
-} else if ($mformpost->is_submitted() && !$mformpost->no_submit_button_pressed()) {
+} else if ($mformpost->is_submitted() && !$mformpost->no_submit_button_pressed() && $fromform = $mformpost->get_data()) {
 
     if (empty($SESSION->fromurl)) {
         $errordestination = $urlfactory->get_forum_view_url_from_forum($forumentity);
     } else {
         $errordestination = $SESSION->fromurl;
     }
-    $fromform = $mformpost->get_data();
+
     $fromform->itemid        = $fromform->message['itemid'];
     $fromform->messageformat = $fromform->message['format'];
     $fromform->message       = $fromform->message['text'];