catalyst / moodle-report_allbackups

This report allows access to all backups on a site - including those stored in all users private files
Other
6 stars 7 forks source link

Error reading from database #1

Closed mudrd8mz closed 4 years ago

mudrd8mz commented 4 years ago

After enabling Course role is "Teacher" in any course from "Miscellaneous" filter setting, I get DB exception on my PostgreSQL test machine:

Error reading from database

Debug info: ERROR: column reference "id" is ambiguous
LINE 1: ...> 'tool_recyclebin' and f.filearea <> 'draft' and id IN (SEL...
^
SELECT COUNT(1) FROM m_files f JOIN m_user u on u.id = f.userid WHERE f.filename like '%.mbz' and f.filename <> '.' and f.component <> 'tool_recyclebin' and f.filearea <> 'draft' and id IN (SELECT userid
FROM m_role_assignments a
INNER JOIN m_context b ON a.contextid=b.id
INNER JOIN m_course c ON b.instanceid=c.id
WHERE b.contextlevel=50 AND a.roleid = $1 AND c.category = $2)
[array (
0 => 3,
1 => 1,
)]
Error code: dmlreadexception
Stack trace:

    line 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
    line 329 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
    line 920 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
    line 1624 of /lib/dml/moodle_database.php: call to pgsql_native_moodle_database->get_records_sql()
    line 1697 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
    line 1907 of /lib/dml/moodle_database.php: call to moodle_database->get_field_sql()
    line 1964 of /lib/tablelib.php: call to moodle_database->count_records_sql()
    line 2019 of /lib/tablelib.php: call to table_sql->query_db()
    line 120 of /report/allbackups/index.php: call to table_sql->out()
mudrd8mz commented 4 years ago

It seems to affect other filter options too:

Debug info: ERROR: column reference "id" is ambiguous
LINE 1: ...STS ( SELECT userid FROM m_user_enrolments ) AND id IN ( S...
^
SELECT COUNT(1) FROM m_files f JOIN m_user u on u.id = f.userid WHERE f.filename like '%.mbz' and f.filename <> '.' and f.component <> 'tool_recyclebin' and f.filearea <> 'draft' and EXISTS ( SELECT userid FROM m_user_enrolments ) AND id IN ( SELECT userid FROM m_user_enrolments )
[array (
)]
Error code: dmlreadexception
Stack trace:

    line 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
    line 329 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
    line 920 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
    line 1624 of /lib/dml/moodle_database.php: call to pgsql_native_moodle_database->get_records_sql()
    line 1697 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
    line 1907 of /lib/dml/moodle_database.php: call to moodle_database->get_field_sql()
    line 1964 of /lib/tablelib.php: call to moodle_database->count_records_sql()
    line 2019 of /lib/tablelib.php: call to table_sql->query_db()
    line 120 of /report/allbackups/index.php: call to table_sql->out()
danmarsden commented 4 years ago

Thanks David - I was planning to remove a bunch of those filters anyway but hadn't noticed they were triggering errors - will tidy that up and update the plugins db next week!