Permalink
Browse files

MDL-31360 Don't use get_in_or_equal if array is empty, tidy up struct…

…ure of $extracaps array
  • Loading branch information...
1 parent 6cc3910 commit 8efa8215506c084727b68d992169abb6d16cd456 @danmarsden danmarsden committed with wdjunaidi Jan 25, 2012
Showing with 8 additions and 8 deletions.
  1. +8 −8 lib/accesslib.php
View
@@ -6380,23 +6380,23 @@ public function get_capabilities() {
}
$modfile = "$CFG->dirroot/mod/$module->name/lib.php";
+ $extracaps = array();
if (file_exists($modfile)) {
include_once($modfile);
$modfunction = $module->name.'_get_extra_capabilities';
if (function_exists($modfunction)) {
$extracaps = $modfunction();
}
}
- if (empty($extracaps)) {
- $extracaps = array();
- }
$extracaps = array_merge($subcaps, $extracaps);
-
- list($extra, $params) = $DB->get_in_or_equal(
- $extracaps, SQL_PARAMS_NAMED, 'cap0');
- $extra = "OR name $extra";
-
+ $extra = '';
+ $params = array();
+ if (!empty($extracaps)) {
+ list($extra, $params) = $DB->get_in_or_equal(
+ $extracaps, SQL_PARAMS_NAMED, 'cap0');
+ $extra = "OR name $extra";
+ }
$sql = "SELECT *
FROM {capabilities}
WHERE (contextlevel = ".CONTEXT_MODULE."

0 comments on commit 8efa821

Please sign in to comment.