drachels/moodle-mod_hotquestion

locallib.php contains SQL quesries that are incompatible with SQLSRV driver

luisdev opened this issue · 2 comments

Using mod_hotquestion version:
$plugin->version = 2021100100;
$plugin->release = "4.0.1 (Build: 2021100100)";

On Moodle version:
$version = 2020061517.04;
$release = '3.9.17+ (Build: 20221011)';

I'm using a MS SQL Server 2012 R2 database for Moodle with the sqlsrv driver:
$CFG->dbtype = 'sqlsrv';

PHP version 7.4.30-nts-Win32-vc15-x64

When I open the /mod/hotquestion/view.php?id=12345 page it throws an error saying the SQL code in two of the queries contain an invalid GROUP BY clause. That's because most of the column names in the SELECT are missing from the GROUP BY clause.

SQLError1

The fix is to change the GROUP·BY statements in lines 279 and 441 and add the missing column names, like this:

279
-- GROUP BY hqq.id, hqr.id, hqv.voter
++ GROUP BY hqq.id, hqr.id, hqv.voter, hqq.hotquestion, hqq.content, hqq.userid, hqq.time, hqq.anonymous, hqq.tpriority, hqq.approved

441
-- GROUP BY q.id
++ GROUP BY q.id, q.hotquestion, q.content, q.userid, q.time, q.anonymous, q.approved, q.tpriority

Hmm, I just noticed you are a few versions behind and using a version of HotQUestion I no longer support, as well as using a version of Moodle that is no longer supported. The latest version of HotQuestion has those fixed, so if you want to upgrade that version of HotQuestion and continue to use it, even though the line number differ, you can copy them to you code.

Closing this> The problem is fixed in supported an current versions.