From 59b8d89ba82a5e68cb3b9910163d3787e666e1ba Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Wed, 28 Oct 2015 11:55:16 +0800 Subject: [PATCH] MDL-51939 mod_forum: Correct empty groupinfo check --- mod/forum/db/upgrade.php | 8 ++++++++ mod/forum/post.php | 2 +- mod/forum/version.php | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/mod/forum/db/upgrade.php b/mod/forum/db/upgrade.php index c26485a33a1..8ac3fedefc3 100644 --- a/mod/forum/db/upgrade.php +++ b/mod/forum/db/upgrade.php @@ -181,5 +181,13 @@ function xmldb_forum_upgrade($oldversion) { upgrade_mod_savepoint(true, 2014051203, 'forum'); } + if ($oldversion < 2014051204) { + // Groupid = 0 is never valid. + $DB->set_field('forum_discussions', 'groupid', -1, array('groupid' => 0)); + + // Forum savepoint reached. + upgrade_mod_savepoint(true, 2014051204, 'forum'); + } + return true; } diff --git a/mod/forum/post.php b/mod/forum/post.php index 5fa7610d614..b40c6193ef5 100644 --- a/mod/forum/post.php +++ b/mod/forum/post.php @@ -840,7 +840,7 @@ if ($fromform = $mform_post->get_data()) { // Before we add this we must check that the user will not exceed the blocking threshold. forum_check_blocking_threshold($thresholdwarning); - if (isset($fromform->groupinfo)) { + if (!empty($fromform->groupinfo)) { // Use the value provided in the dropdown group selection. $fromform->groupid = $fromform->groupinfo; diff --git a/mod/forum/version.php b/mod/forum/version.php index 7aa50c67dd3..98c9fed5d2a 100644 --- a/mod/forum/version.php +++ b/mod/forum/version.php @@ -24,6 +24,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2014051203; // The current module version (Date: YYYYMMDDXX) +$plugin->version = 2014051204; // The current module version (Date: YYYYMMDDXX) $plugin->requires = 2014050800; // Requires this Moodle version $plugin->component = 'mod_forum'; // Full name of the plugin (used for diagnostics)