-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
2.1
-
None
-
Postgresql 9.0, Apache2, Moodle on master
-
Microsoft SQL
-
-
MOODLE_21_STABLE
Navigating to the Submission Inbox (e.g. http://moodle.local/mod/turnitintool/view.php?id=2&do=allsubmissions), and then to any other page (e.g. http://moodle.local/mod/turnitintool/view.php?id=2&do=intro) returns a database error:
Debug info: ERROR: invalid input syntax for integer: ""
SELECT COUNT('x') FROM mdl_turnitintool_submissions WHERE userid = $1 AND turnitintoolid = $2
[array (
0 => '',
1 => '1',
)]
Stack trace:
line 391 of /lib/dml/moodle_database.php: dml_read_exception thrown
line 232 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
line 678 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
line 1278 of /lib/dml/moodle_database.php: call to pgsql_native_moodle_database->get_records_sql()
line 1353 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
line 1524 of /lib/dml/moodle_database.php: call to moodle_database->get_field_sql()
line 1507 of /lib/dml/moodle_database.php: call to moodle_database->count_records_sql()
line 1490 of /lib/dml/moodle_database.php: call to moodle_database->count_records_select()
line 6225 of /mod/turnitintool/lib.php: call to moodle_database->count_records()
line 4365 of /mod/turnitintool/lib.php: call to turnitintool_count_records()
line 67 of /mod/turnitintool/view.php: call to turnitintool_update_choice_cookie()
On further examination, it appears that lib.php::turnitintool_update_choice_cookie() sets the values of $newUserCookie and $newCountCookie without checking whether the cookie has any information.
As a result, the explodes on lines 4354 and 4358 explode an empty string, which returns an array containing on empty string.
When the plugin later (line 4360) loops through this array, it attempts to query the database for a userid which does not exist as it's an empty string.