From 01beeae9938b30003502bea75b3a5f7e41b515de Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Mon, 4 Oct 2010 07:50:12 +0000 Subject: [PATCH] MDL-24505 limit max number of admin candidates --- admin/roles/lib.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/admin/roles/lib.php b/admin/roles/lib.php index d77694d66fe..d8a492d5ce9 100644 --- a/admin/roles/lib.php +++ b/admin/roles/lib.php @@ -1519,6 +1519,14 @@ class admins_potential_selector extends user_selector_base { $order = ' ORDER BY lastname ASC, firstname ASC'; $params['localmnet'] = $CFG->mnet_localhost_id; // it could be dangerous to make remote users admins and also this could lead to other problems + // Check to see if there are too many to show sensibly. + if (!$this->is_validating()) { + $potentialcount = $DB->count_records_sql($countfields . $sql, $params); + if ($potentialcount > 100) { + return $this->too_many_results($search, $potentialcount); + } + } + $availableusers = $DB->get_records_sql($fields . $sql . $order, $params); if (empty($availableusers)) {