mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-63926 block_recentlyaccesseditems: Improved get_contexts_for_userid
Updated the provider::get_contexts_for_userid method, to prevent false positives. Previously, the user context would always be returned, now the method checks data exists for the block first.
This commit is contained in:
parent
dccda6546b
commit
13bd038912
@ -69,9 +69,12 @@ class provider implements \core_privacy\local\metadata\provider, \core_privacy\l
|
||||
*/
|
||||
public static function get_contexts_for_userid(int $userid) : contextlist {
|
||||
$params = ['userid' => $userid, 'contextuser' => CONTEXT_USER];
|
||||
$sql = "SELECT id
|
||||
FROM {context}
|
||||
WHERE instanceid = :userid and contextlevel = :contextuser";
|
||||
$sql = "SELECT c.id
|
||||
FROM {context} c
|
||||
JOIN {block_recentlyaccesseditems} b
|
||||
ON b.userid = c.instanceid
|
||||
WHERE c.instanceid = :userid
|
||||
AND c.contextlevel = :contextuser";
|
||||
$contextlist = new contextlist();
|
||||
$contextlist->add_from_sql($sql, $params);
|
||||
return $contextlist;
|
||||
|
Loading…
x
Reference in New Issue
Block a user