Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempting to get the HTML report leads to an error #1

Open
mudrd8mz opened this issue Sep 30, 2016 · 2 comments
Open

Attempting to get the HTML report leads to an error #1

mudrd8mz opened this issue Sep 30, 2016 · 2 comments

Comments

@mudrd8mz
Copy link

Testing the report on a course running on a PostgreSQL site seems to lead to a notice:

Notice: Use of undefined constant EXCLUDE_GROUP_MEMBERS - assumed 'EXCLUDE_GROUP_MEMBERS' in report/ncccscensus/lib.php on line 1069
Call Stack
#   Time    Memory  Function    Location
1   0.0002  267984  {main}( )   ../index.php:0
2   0.1887  10863984    report_ncccscensus_generate_report( )   ../index.php:63
3   0.1887  10864536    report_ncccscensus_get_users( ) ../lib.php:714

followed by a DB error:

Error reading from database

More information about this error

Debug info: ERROR: operator does not exist: character varying = bigint
LINE 13: AND gi.itemmodule = "forum"
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
SELECT u.id AS userid, fp.id AS postid, gi.id AS giid, u.firstname, u.lastname, u.idnumber, gg.overridden,
fp.message, gi.itemname, gg.finalgrade, fp.created AS timesubmitted, fp.modified AS timecreated,
u.firstnamephonetic, u.lastnamephonetic, u.middlename, u.alternatename
FROM mdl_forum_posts fp
INNER JOIN mdl_forum_discussions fd ON fd.id = fp.discussion
INNER JOIN mdl_forum f ON f.id = fd.forum
INNER JOIN mdl_grade_items gi ON gi.iteminstance = fd.forum
LEFT JOIN mdl_grade_grades gg ON gg.itemid = gi.id AND gg.userid = fp.userid
INNER JOIN mdl_user u ON u.id = fp.userid AND fp.userid in (105,110,103,108,104,106,112,107,111,109,3)
WHERE fd.course = $1
AND f.assessed > 0
AND fp.userid != 0
AND gi.itemmodule = "forum"
AND fp.created >= $2
AND fp.created <= $3
GROUP BY fp.userid, u.id, fp.id, gi.id, u.firstname, u.lastname, u.idnumber, fp.message, gi.itemname, gg.finalgrade,
fp.created
ORDER BY fp.created ASC, u.lastname ASC, u.firstname ASC
[array (
0 => 3,
1 => 1454108400,
2 => 1475272799,
)]
Error code: dmlreadexception

Stack trace:
line 443 of /lib/dml/moodle_database.php: dml_read_exception thrown
line 244 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
line 744 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
line 1192 of /report/ncccscensus/lib.php: call to pgsql_native_moodle_database->get_recordset_sql()
line 716 of /report/ncccscensus/lib.php: call to report_ncccscensus_build_grades_array()
line 63 of /report/ncccscensus/index.php: call to report_ncccscensus_generate_report()
@mudrd8mz
Copy link
Author

I believe the DB error is caused by this SQL in the report_ncccscensus_build_grades_array()

AND gi.itemmodule = "forum"

In PostgreSQL, double quotes make the forum be interpretted at the column name, not a constant (https://wiki.postgresql.org/wiki/Things_to_find_out_about_when_moving_from_MySQL_to_PostgreSQL). Please replace with single quotes, or use argument placeholders and pass even constant values via $params to be cross-db safe.

@mchurchward
Copy link

mchurchward commented Oct 3, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants