Permalink
Browse files

MDL-36091 added debugging() calls in blocks of code marked as "should…

… never happen"
  • Loading branch information...
1 parent 06d8f38 commit c90e6b4644eea2934e2858e4401655c46be90ab0 @andyjdavis andyjdavis committed with danpoltawski Oct 26, 2012
Showing with 9 additions and 1 deletion.
  1. +1 −0 admin/tool/uploaduser/index.php
  2. +1 −0 enrol/manual/locallib.php
  3. +2 −0 grade/edit/outcome/index.php
  4. +2 −0 lib/accesslib.php
  5. +3 −1 lib/datalib.php
@@ -535,6 +535,7 @@
}
if (!property_exists($user, $column) or !property_exists($existinguser, $column)) {
// this should never happen
+ debugging("Could not find $column on the user objects", DEBUG_DEVELOPER);
continue;
}
if ($updatetype == UU_UPDATE_MISSING) {
@@ -406,6 +406,7 @@ function enrol_manual_migrate_plugin_enrolments($enrol) {
if (!$minstance) {
// This should never happen unless adding of default instance fails unexpectedly.
+ debugging('Failed to find manual enrolment instance', DEBUG_DEVELOPER);
continue;
}
@@ -132,6 +132,7 @@
$scale = $outcome->load_scale();
if (empty($scale->id)) { // hopefully never happens
$line[] = $scale->get_name();
+ debugging("Found a scale with no ID ({$scale->get_name()}) while outputting course outcomes", DEBUG_DEVELOPER);
} else {
if (empty($scale->courseid)) {
$caneditthisscale = $caneditsystemscales;
@@ -181,6 +182,7 @@
$scale = $outcome->load_scale();
if (empty($scale->id)) { // hopefully never happens
$line[] = $scale->get_name();
+ debugging("Found a scale with no ID ({$scale->get_name()}) while outputting global outcomes", DEBUG_DEVELOPER);
} else {
if (empty($scale->courseid)) {
$caneditthisscale = $caneditsystemscales;
View
@@ -393,6 +393,7 @@ function has_capability($capability, context $context, $user = null, $doanything
if (!isset($USER->id)) {
// should never happen
$USER->id = 0;
+ debugging('Capability check being performed on a user with no ID.', DEBUG_DEVELOPER);
}
// make sure there is a real user specified
@@ -2062,6 +2063,7 @@ function can_access_course(stdClass $course, $user = null, $withcapability = '',
if (!isset($USER->id)) {
// should never happen
$USER->id = 0;
+ debugging('Course access check being performed on a user with no ID.', DEBUG_DEVELOPER);
}
// make sure there is a user specified
View
@@ -57,7 +57,9 @@ function get_admin() {
static $mainadmin = null;
static $prevadmins = null;
- if (empty($CFG->siteadmins)) { // Should not happen on an ordinary site.
+ if (empty($CFG->siteadmins)) {
+ // Should not happen on an ordinary site.
+ // It does however happen during unit tests.
return false;
}

0 comments on commit c90e6b4

Please sign in to comment.