moodleou / moodle-mod_forumng

ForumNG forum module for Moodle
19 stars 20 forks source link

MDL 2.7 User Participation error #39

Closed aspark21 closed 9 years ago

aspark21 commented 9 years ago

Moodle 2.7 latest ForumNG latest master branch DB: MariaDB / MySQL

The following stack trace is generated for the "Error reading from database" when trying to view the "Participation by user" under Moodle 2.7 e.g http://your.moodle.site/mod/forumng/feature/userposts/list.php?id=529

Debug info: FUNCTION moodledb.COUNT does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT u.id,u.picture,u.firstname,u.lastname,u.firstnamephonetic,u.lastnamephonetic,u.middlename,u.alternatename,u.imagealt,u.email,u.username, COALESCE(ta.numposts, 0) AS numposts, COALESCE(td.numdiscussions, 0) AS numdiscussions FROM mdl_user u LEFT JOIN ( SELECT fp.userid, COUNT (fp.userid) AS numposts FROM mdl_forumng_posts fp INNER JOIN mdl_forumng_discussions fd ON fd.id = fp.discussionid AND fd.postid <> fp.id WHERE fd.forumngid = ? AND fd.deleted = 0 AND fp.deleted = 0 AND fp.oldversion = 0 GROUP BY (fp.userid)) ta ON u.id = ta.userid

LEFT JOIN ( SELECT fp.userid, COUNT (fp.userid) AS numdiscussions FROM mdl_forumng_posts fp INNER JOIN mdl_forumng_discussions fd ON fd.postid = fp.id WHERE fd.forumngid = ? AND fd.deleted = 0 AND fp.deleted = 0 AND fp.oldversion = 0 GROUP BY (fp.userid)) td ON u.id = td.userid WHERE u.id IN (SELECT DISTINCT eu1_u.id FROM mdl_user eu1_u JOIN mdl_user_enrolments eu1_ue ON eu1_ue.userid = eu1_u.id JOIN mdl_enrol eu1_e ON (eu1_e.id = eu1_ue.enrolid AND eu1_e.courseid = ?) WHERE eu1_u.deleted = 0 AND eu1_u.id <> ?) ORDER BY u.lastname ASC, u.firstname ASC, u.id ASC LIMIT 0, 100 [array ( 0 => '16', 1 => '16', 2 => '26', 3 => '1', )] 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 208 of /mod/forumng/feature/userposts/list.php: call to mysqli_native_moodle_database->get_records_sql()

jason-platts commented 9 years ago

Thanks for spotting this. Another issue where postgres is very forgiving so we don't spot these silly mistakes.

In this case I'm guessing the space after the COUNT's is causing the problem.