]> git.mjollnir.org Git - moodle.git/commitdiff
accesslib: Nice debug developer warning if you call get_users_with_capability without...
authortjhunt <tjhunt>
Wed, 14 Jan 2009 04:44:20 +0000 (04:44 +0000)
committertjhunt <tjhunt>
Wed, 14 Jan 2009 04:44:20 +0000 (04:44 +0000)
lib/accesslib.php

index a6e26dfd48d4c4bee86e8aa14ada15674f0e894f..593b4575546909bc0f96d0daa04d2097d294cc18 100755 (executable)
@@ -4632,8 +4632,8 @@ function get_default_course_role($course) {
  *               case users having any of those capabilities will be returned.
  *               For performance reasons, you are advised to put the capability
  *               that the user is most likely to have first.
- * @param $fields - fields to be pulled
- * @param $sort - the sort order
+ * @param $fields - fields to be pulled. The user table is aliased to 'u'. u.id MUST be included.
+ * @param $sort - the sort order. Default is lastaccess time.
  * @param $limitfrom - number of records to skip (offset)
  * @param $limitnum - number of records to fetch
  * @param $groups - single group or array of groups - only return
@@ -4796,6 +4796,11 @@ function get_users_by_capability($context, $capability, $fields='', $sort='',
         } else {
             $fields = 'u.*';
         }
+    } else {
+        if (debugging('', DEBUG_DEVELOPER) && strpos($fields, 'u.*') === false &&
+                strpos($fields, 'u.id') === false) {
+            debugging('u.id must be included in the list of fields passed to get_users_by_capability.', DEBUG_DEVELOPER);
+        }
     }
 
     /// Set up default sort