moodleou / moodle-mod_forumng

ForumNG forum module for Moodle
19 stars 20 forks source link

Student can't access any posts #51

Closed mfindlayated closed 8 years ago

mfindlayated commented 8 years ago

Hi Folks,

We have a student who is experiencing an issue when trying to view any forumNG post. Error when debugging on below.

We are on Moodle 2.8.6+ and the version of ForumNG is 2015060500.

Thanks in advance, Mark.

" Debug info: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'read FROM mdl_forumng_posts fp INNER JOIN mdl_user u ON fp.userid = u.id' at line 10

SELECT fp.*, u.id as u_id,u.username as u_username,u.picture as u_picture,u.url as u_url,u.imagealt as u_imagealt,u.email as u_email,u.maildisplay as u_maildisplay,u.mailformat as u_mailformat,u.maildigest as u_maildigest,u.emailstop as u_emailstop,u.deleted as u_deleted,u.auth as u_auth,u.timezone as u_timezone,u.lang as u_lang,u.idnumber as u_idnumber,u.firstnamephonetic as u_firstnamephonetic,u.lastnamephonetic as u_lastnamephonetic,u.middlename as u_middlename,u.alternatename as u_alternatename,u.firstname as u_firstname,u.lastname as u_lastname, eu.id as eu_id,eu.username as eu_username,eu.picture as eu_picture,eu.url as eu_url,eu.imagealt as eu_imagealt,eu.idnumber as eu_idnumber,eu.email as eu_email,eu.firstnamephonetic as eu_firstnamephonetic,eu.lastnamephonetic as eu_lastnamephonetic,eu.middlename as eu_middlename,eu.alternatename as eu_alternatename,eu.firstname as eu_firstname,eu.lastname as eu_lastname, du.id as du_id,du.username as du_username,du.picture as du_picture,du.url as du_url,du.imagealt as du_imagealt,du.idnumber as du_idnumber,du.email as du_email,du.firstnamephonetic as du_firstnamephonetic,du.lastnamephonetic as du_lastnamephonetic,du.middlename as du_middlename,du.alternatename as du_alternatename,du.firstname as du_firstname,du.lastname as du_lastname

, ff.flagged

, fr.time AS read FROM mdl_forumng_posts fp INNER JOIN mdl_user u ON fp.userid = u.id LEFT JOIN mdl_user eu ON fp.edituserid = eu.id LEFT JOIN mdl_user du ON fp.deleteuserid = du.id

LEFT JOIN mdl_forumng_flags ff ON ff.postid = fp.id AND ff.userid = ?

LEFT JOIN mdl_forumng_read_posts fr ON fr.postid = fp.id AND fr.userid = ? WHERE fp.discussionid=? AND fp.oldversion=0 ORDER BY fp.created

[array ( 0 => '994', 1 => '994', 2 => '244', )] Error code: dmlreadexception

Stack trace: line 443 of /lib/dml/moodle_database.php: dml_read_exception thrown line 1080 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end() line 1036 of /mod/forumng/mod_forumng_post.php: call to mysqli_native_moodle_database->get_records_sql() line 661 of /mod/forumng/mod_forumng_discussion.php: call to mod_forumng_post::query_posts() line 41 of /mod/forumng/renderer.php: call to mod_forumng_discussion->get_root_post() line 290 of /mod/forumng/type/general/forumngtype_general.php: call to mod_forumng_renderer->render_discussion() line 104 of /mod/forumng/discuss.php: call to forumngtype_general->print_discussion_page() "

jason-platts commented 8 years ago

This is the same as issue #47 (which is now closed).

Unfortunately the patch has not been pushed upstream to github yet using our semi-automated process (the person that does this is away this week and I forgot to ask them before they went on leave - that doesn't help you much!).

Here is the fix:

diff --git a/mod/forumng/mod_forumng_post.php b/mod/forumng/mod_forumng_post.php
index 1dfa501..f6e7143 100644
--- a/mod/forumng/mod_forumng_post.php
+++ b/mod/forumng/mod_forumng_post.php
@@ -502,8 +502,8 @@ WHERE
         $timeread = $this->discussion->get_time_read();

         // If later manual mark post as read record then use that as read time.
-        if (!empty($this->postfields->read) && $this->postfields->read > $timeread) {
-            $timeread = $this->postfields->read;
+        if (!empty($this->postfields->uread) && $this->postfields->uread > $timeread) {
+            $timeread = $this->postfields->uread;
         }

         // Compare date to discussion read data.
@@ -999,7 +999,7 @@ WHERE
         }

         if ($read) {
-            $readquery = ', fr.time AS read';
+            $readquery = ', fr.time AS uread';
             $readjoin = "LEFT JOIN {forumng_read_posts} fr ON fr.postid = fp.id AND fr.userid = ?";
             $queryparams[] = $userid;
         } else {
sammarshallou commented 8 years ago

For info, I did the thing that pushes changes to our github. (Don't know specifics about this change but assume it is up there now. :)