Skip to content

Commit 746e375

Browse files
t-schroederMarvin-Kirch
authored andcommitted
MDL-81481 assign grading: speed up assign 'View all submissions' page
the 'View all submissions' page was fairly slow when dealing with large databases. Solution: Utilize a static 'capability_checker' in 'filter_user_list' to prevent reinitialization. Requests made by 'get_users_by_capability' will be cached, thus enhancing performance for large databases.
1 parent 263b3c3 commit 746e375

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

availability/classes/info.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,12 @@ public function filter_user_list(array $users) {
634634
return $users;
635635
}
636636
$tree = $this->get_availability_tree();
637-
$checker = new capability_checker($this->get_context());
637+
static $checkers = [];
638+
$context = $this->get_context();
639+
if (!array_key_exists($context->id, $checkers)) {
640+
$checkers[$context->id] = new capability_checker($context);
641+
}
642+
$checker = $checkers[$context->id];
638643

639644
// Filter using availability tree.
640645
$this->modinfo = get_fast_modinfo($this->get_course());

0 commit comments

Comments
 (0)