-
Bug
-
Resolution: Fixed
-
Minor
-
3.4, 3.5.4, 3.6.2, 3.7
-
MOODLE_34_STABLE, MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE
-
MOODLE_35_STABLE, MOODLE_36_STABLE
-
MDL-61535-master -
Hello everyone,
This is a little improvement I made for a client and I share it here.
In the functions report_security_check_riskxss and report_security_check_riskbackup, we had some performance issues and I fixed it by replacing "SELECT rcx.*" by "SELECT DISTINCT rcx.contextid, rcx.roleid".
Here's the full diff
diff --git a/report/security/locallib.php b/report/security/locallib.php
|
index 59123c49a0..eaa71bd98d 100644 |
--- a/report/security/locallib.php
|
+++ b/report/security/locallib.php
|
@@ -466,7 +466,7 @@ function report_security_check_riskxss($detailed=false) { |
|
$params = array('capallow'=>CAP_ALLOW); |
|
- $sqlfrom = "FROM (SELECT rcx.*
|
+ $sqlfrom = "FROM (SELECT DISTINCT rcx.contextid, rcx.roleid
|
FROM {role_capabilities} rcx
|
JOIN {capabilities} cap ON (cap.name = rcx.capability AND ".$DB->sql_bitand('cap.riskbitmask', RISK_XSS)." <> 0) |
WHERE rcx.permission = :capallow) rc,
|
@@ -755,7 +755,7 @@ function report_security_check_riskbackup($detailed=false) { |
$params = array('capability'=>'moodle/backup:userinfo', 'permission'=>CAP_ALLOW, 'context1'=>CONTEXT_COURSE, 'context2'=>CONTEXT_COURSE); |
|
$sqluserinfo = "
|
- FROM (SELECT rcx.*
|
+ FROM (SELECT DISTINCT rcx.contextid, rcx.roleid
|
FROM {role_capabilities} rcx
|
WHERE rcx.permission = :permission AND rcx.capability = :capability) rc,
|
{context} c,
|
Kind regards,
Olivier