Sticky Notes is a Moodle activity for creating an interactive post-it wall. Students can create, move and vote for notes, under supervision of teacher which can define colors, lock fucntionnalities...
Other
4
stars
6
forks
source link
Unit test errors due to missing param in add_from_sql query #34
vendor/bin/phpunit --filter {insert test name above} admin/tool/dataprivacy/tests/expired_contexts_test.php
Unit test error:
1) tool_dataprivacy\expired_contexts_test::test_process_course_context_with_override_unexpired_role
Unexpected debugging() call detected.
Debugging: ERROR: missing param "modname" in query
* line 1282 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->fix_sql_params()
* line 56 of /privacy/classes/local/request/userlist.php: call to mysqli_native_moodle_database->get_records_sql()
* line 162 of /mod/stickynotes/classes/privacy/provider.php: call to core_privacy\local\request\userlist->add_from_sql()
* line 8151 of /lib/moodlelib.php: call to mod_stickynotes\privacy\provider::get_users_in_context()
...
Problem:"mod/stickynotes/classes/privacy/provider.php" line 151 of 335
public static function get_users_in_context(userlist $userlist) {
$context = $userlist->get_context();
if (!is_a($context, \context_module::class)) {
return;
}
$params = [
'instanceid' => $context->instanceid,
'modulename' => 'stickynotes', <------------------------ should be 'modname'
];
// Notes authors.
$sql = "SELECT sn.userid
FROM {course_modules} cm
JOIN {modules} m ON m.id = cm.module AND m.name = :modname
JOIN {stickynotes} s ON s.id = cm.instance
JOIN {stickynotes_column} sc ON sc.stickyid = s.id
JOIN {stickynotes_note} sn ON sn.stickycolid = sc.id
WHERE cm.id = :instanceid";
$userlist->add_from_sql('userid', $sql, $params);
// Votes.
$sql = "SELECT sv.userid
FROM {course_modules} cm
JOIN {modules} m ON m.id = cm.module AND m.name = :modname
JOIN {stickynotes} s ON s.id = cm.instance
JOIN {stickynotes_column} sc ON sc.stickyid = s.id
JOIN {stickynotes_note} sn ON sn.stickycolid = sc.id
JOIN {stickynotes_vote} sv ON sv.stickynoteid = sn.id
WHERE cm.id = :instanceid";
$userlist->add_from_sql('userid', $sql, $params);
}
Description: Multiple errors are occurring in the following unit tests due to incorrect param name "modulename" - "modname" is expected instead.
Test command:
Unit test error:
Problem:
"mod/stickynotes/classes/privacy/provider.php" line 151 of 335