]> git.mjollnir.org Git - moodle.git/commitdiff
debugging and error reporting level fixes and improvements MDL-6671
authorskodak <skodak>
Sat, 23 Sep 2006 09:38:39 +0000 (09:38 +0000)
committerskodak <skodak>
Sat, 23 Sep 2006 09:38:39 +0000 (09:38 +0000)
16 files changed:
admin/index.php
enrol/ldap/enrol_ldap_sync.php
file.php
filter/algebra/pix.php
filter/tex/pix.php
lang/en_utf8/admin.php
lib/accesslib.php
lib/adminlib.php
lib/moodlelib.php
lib/setup.php
lib/weblib.php
mod/glossary/exportfile.php
mod/quiz/quizfile.php
rss/file.php
user/pix.php
user/pixgroup.php

index 8f620b5c4857df03a5890d89f9d77a33c8868ed8..8a90157252471bd58b463e129c82a8bd98ffcf46 100644 (file)
     if (! $maintables) {
     /// hide errors from headers in case debug enabled in config.php
         $origdebug = $CFG->debug;
-        $CFG->debug = 5;
+        $CFG->debug = DEBUG_MINIMAL;
         error_reporting($CFG->debug);
         if (empty($agreelicence)) {
             $strlicense = get_string("license");
 
             // hide errors from headers in case debug is enabled
             $origdebug = $CFG->debug;
-            $CFG->debug = 5;
+            $CFG->debug = DEBUG_MINIMAL;
             error_reporting($CFG->debug);
 
             // logout in case we are upgrading from pre 1.7 version - prevention of weird session problems
index 4b68941585981b3b9a78c013ffee36ceed4af06e..d56cb119c1119fbcad16f4318e76c2acbe16a17d 100755 (executable)
@@ -14,7 +14,7 @@
     require_once($CFG->dirroot . "/enrol/ldap/enrol.php");
 
     // ensure errors are well explained
-    $CFG->debug = E_NOTICE;
+    $CFG->debug = DEBUG_NORMAL;
 
     // update enrolments -- these handlers should autocreate courses if required
     $enrol = new enrolment_plugin_ldap();
index 2984ab08578ceee72cbb36122914db0a87704eae..92232ebf7b85271c41a585e4b3c3ea17f1243ca9 100644 (file)
--- a/file.php
+++ b/file.php
         $lifetime = $CFG->filelifetime;
     }
 
-    // remove moodle specific debug messages by switching the sign bit in error level bitmask
-    if ($CFG->debug > 0) {
-        $CFG->debug = $CFG->debug | 0x80000000;
-    }
+    // disable moodle specific debug messages
+    disable_debugging();
 
     $relativepath = get_file_argument('file.php');
     $forcedownload = optional_param('forcedownload', 0, PARAM_BOOL);
index 3e34c92f212bd80f3c73c291d174dd33d8285adf..56d81639979b0dfd55c1c4afc530614b9812fdcd 100644 (file)
@@ -16,6 +16,9 @@
         }
     }
 
+    // disable moodle specific debug messages
+    disable_debugging();
+
     require_once($CFG->libdir.'/filelib.php');
 
     $CFG->texfilterdir     = 'filter/tex';
index 37bed2d1d3456a76dcd290a26de64249a674673d..b98d5fedd55adc001960f119d012cd935fc3eca9 100644 (file)
@@ -16,6 +16,9 @@
         }
     }
 
+    // disable moodle specific debug messages
+    disable_debugging();
+
     require_once($CFG->libdir.'/filelib.php');
     require_once('defaultsettings.php' );
     require_once('latex.php');
index 687255a57e8e86ace2967128f1cec11e22cff38a..b9b58035b6264dd6b95b5103616b11fa59167214 100644 (file)
@@ -144,7 +144,7 @@ $string['sessiontimeout'] = 'Timeout';
 $string['sessioncookie'] = 'Cookie prefix';
 $string['sessioncookiepath'] = 'Cookie path';
 $string['enablerssfeeds'] = 'Enable RSS feeds';
-$string['debug'] = 'Debug notices';
+$string['debug'] = 'Debug messages';
 $string['perfdebug'] = 'Performance info';
 $string['enablestats'] = 'Enable statistics';
 $string['statsfirstrun'] = 'Maximum processing interval';
@@ -304,13 +304,11 @@ $string['dbmigratewarning2'] = '<b>Warning: You are about to start the database
 $string['dbmigrateconnecerror'] = 'Could not connect to the database specified.';
 $string['dbmigrateencodingerror'] = 'The database specified has encoding $a rather than required UNICODE/UTF8.<br />Please specify another.';
 $string['dbmigratepostgres'] = 'It seems that you are using PostgreSQL as the database server. To continue the migration process you need to manually create a new database with encoding \"UNICODE\"(PostgreSQL 7) or \"UTF8\" (PostgreSQL 8) to store the migrated data. Please enter your new database connection settings below to continue:';
-$string['debugnone'] = 'Do not show any debugging notices';
-$string['debugerror'] = 'E_ERROR: Show only fatal errors';
-$string['debugwarning'] = 'E_WARNING: show only serious warnings';
-$string['debugparse'] = 'E_PARSE: show parsing errors';
-$string['debugnotice'] = 'E_NOTICE: show informational notices';
-$string['debugall'] = 'E_ALL: show all reasonable feedback';
-$string['debugstrict'] = 'E_STRICT: show absolutely everything, even very minor errors';
+$string['debugnone'] = 'NONE: Do not show any errors or warnings';
+$string['debugminimal'] = 'MINIMAL: Show only fatal errors';
+$string['debugnormal'] = 'NORMAL: Show errors, warnings and notices';
+$string['debugall'] = 'ALL: Show all reasonable PHP debug messages';
+$string['debugdeveloper'] = 'DEVELOPER: extra Moodle debug messages for developers';
 $string['density'] = 'Density';
 $string['download'] = 'Download';
 $string['edithelpdocs'] = 'Edit help documents';
index 321b08e071436e4f539e261444e13ce8cae3d761..c1d90dcbc87275e79ac8458e0f7b9afd1a73cab3 100755 (executable)
@@ -419,7 +419,7 @@ function capability_search($capability, $context, $capabilities) {
     global $USER, $CFG;
 
     if (isset($capabilities[$context->id][$capability])) {
-        debugging("Found $capability in context $context->id at level $context->contextlevel: ".$capabilities[$context->id][$capability], E_ALL);
+        debugging("Found $capability in context $context->id at level $context->contextlevel: ".$capabilities[$context->id][$capability], DEBUG_DEVELOPER);
         return ($capabilities[$context->id][$capability]);
     }
 
@@ -481,7 +481,7 @@ function capability_search($capability, $context, $capabilities) {
             error ('This is an unknown context!');
         return false;
     }
-    debugging("Found $capability recursively from context $context->id at level $context->contextlevel: $permission", E_ALL);
+    debugging("Found $capability recursively from context $context->id at level $context->contextlevel: $permission", DEBUG_DEVELOPER);
 
     return $permission;
 }
@@ -1361,7 +1361,7 @@ function get_roles_with_capability($capability, $permission=NULL, $context='') {
 function role_assign($roleid, $userid, $groupid, $contextid, $timestart=0, $timeend=0, $hidden=0, $enrol='manual') {
     global $USER, $CFG;
 
-    debugging("Assign roleid $roleid userid $userid contextid $contextid", E_ALL);
+    debugging("Assign roleid $roleid userid $userid contextid $contextid", DEBUG_DEVELOPER);
 
 /// Do some data validation
 
@@ -2765,4 +2765,4 @@ function get_users_from_role_on_context($role, $context) {
                                   AND roleid = $role->id");
 }
 
-?>
+?>
\ No newline at end of file
index 7841dd0e27ea7da1f3b496d55fcb20a02a4b0a9f..51f51330f4fd705c2dd4e574392ab3eefb19f79e 100644 (file)
@@ -2137,13 +2137,11 @@ class admin_setting_special_debug extends admin_setting_configselect {
         $name = 'debug';
         $visiblename = get_string('debug', 'admin');
         $description = get_string('configdebug', 'admin');
-        $choices = array( 0         => get_string('debugnone', 'admin'),
-                          E_ERROR   => get_string('debugerror', 'admin'),
-                          E_WARNING => get_string('debugwarning', 'admin'),
-                          E_PARSE   => get_string('debugparse', 'admin'),
-                          E_NOTICE  => get_string('debugnotice', 'admin'),
-                          E_ALL     => get_string('debugall', 'admin'),
-                          2048      => get_string('debugstrict', 'admin')   //  E_STRICT is php5 only
+        $choices = array( DEBUG_NONE      => get_string('debugnone', 'admin'),
+                          DEBUG_MINIMAL   => get_string('debugminimal', 'admin'),
+                          DEBUG_NORMAL    => get_string('debugnormal', 'admin'),
+                          DEBUG_ALL       => get_string('debugall', 'admin'), 
+                          DEBUG_DEVELOPER => get_string('debugdeveloper', 'admin') 
                         );
         parent::admin_setting_configselect($name, $visiblename, $description, '', $choices);
     }
@@ -2151,12 +2149,6 @@ class admin_setting_special_debug extends admin_setting_configselect {
     function get_setting() {
         global $CFG;
         if (isset($CFG->debug)) {
-            if ($CFG->debug == 7) {   // Old values
-                return 1;
-            }
-            if ($CFG->debug == 15) {  // Old values
-                return 16;
-            }
             return $CFG->debug;
         } else {
             return NULL;
index eed3e3c7b90b7a3ad006a4845df920c757fe0efc..e1cfc3905d612e77e1062d7cf79f7acba8c9c668 100644 (file)
@@ -213,6 +213,17 @@ define('PARAM_SEQUENCE',  0x8000);
  */
 define('PAGE_COURSE_VIEW', 'course-view');
 
+/// Debug levels ///
+/** no warnings at all */
+define ('DEBUG_NONE', 0);
+/** E_ERROR | E_PARSE */
+define ('DEBUG_MINIMAL', 5);
+/** E_ERROR | E_PARSE | E_WARNING | E_NOTICE */
+define ('DEBUG_NORMAL', 15);
+/** E_ALL without E_STRICT and E_RECOVERABLE_ERROR for now */
+define ('DEBUG_ALL', 2047);
+/** DEBUG_ALL with extra Moodle debug messages - (DEBUG_ALL | 32768) */
+define ('DEBUG_DEVELOPER', 34815);
 
 /// PARAMETER HANDLING ////////////////////////////////////////////////////
 
@@ -6698,4 +6709,4 @@ function loadeditor($args) {
 
 
 // vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
-?>
+?>
\ No newline at end of file
index 9df6bb1f339a4d665f0fea4eede6778aaf555354..b1a969cef9cebabee5ff0b0f92101abd8b983d69 100644 (file)
@@ -255,7 +255,7 @@ global $HTTPSPAGEREQUIRED;
 
 /// Set error reporting back to normal
     if ($originaldatabasedebug == -1) {
-        $CFG->debug = E_PARSE;
+        $CFG->debug = DEBUG_MINIMAL;
     } else {
         $CFG->debug = $originaldatabasedebug;
     }
index e38296995b736f88ee4acaf232047311c68e68c2..633d1ef7effc425ac6bc6a4a5e074911641eed81 100644 (file)
@@ -5341,19 +5341,19 @@ function page_doc_link($text='', $iconpath='') {
 }
 
 /**
- * Returns true if the current site debugging settings are equal 
- * to the specified level: E_NOTICE, E_ALL, E_STRICT etc
+ * Returns true if the current site debugging settings are equal or above specified level.
  * eg use like this:
  *
- * 1)  debugging('a normal notice');
- * 2)  debugging('something really picky', E_STRICT);
- * 3)  if (debugging()) { echo "a bunch of commands could be here" } 
+ * 1)  debugging('a normal debug notice');
+ * 2)  debugging('something really picky', DEBUG_ALL);
+ * 3)  debugging('annoying debug message only for develpers', DEBUG_DEVELOPER);
+ * 4)  if (debugging()) { echo "a bunch of commands could be here" } 
  *
  * @param string $message a message to print
  * @param int $level the level at which this debugging statement should show
  * @return bool
  */
-function debugging($message='', $level=E_NOTICE) {
+function debugging($message='', $level=DEBUG_NORMAL) {
 
     global $CFG;
 
@@ -5370,5 +5370,13 @@ function debugging($message='', $level=E_NOTICE) {
     return false;
 }
 
+/**
+ * Disable debug messages from debugging(), while keeping PHP error reporting level as is.
+ */
+function disable_debugging() {
+    global $CFG;
+    $CFG->debug = $CFG->debug | 0x80000000; // switch the sign bit in integer number ;-)
+}
+
 // vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
 ?>
index 4be4cdca468a865d95713371fc64f1bd12607231..0854b9ec1d2bea54734098eaa20739408f2575a1 100644 (file)
@@ -3,6 +3,9 @@
     require_once("../../config.php");
     require_once("lib.php");
 
+    // disable moodle specific debug messages
+    disable_debugging();
+
     $id = required_param('id', PARAM_INT);      // Course Module ID
 
     $l   = optional_param('l','', PARAM_ALPHANUM);
index 5ba5477078cd0da174a011718cc3d11c5576de67..44d3b0f9348a74bcf81804613d3693004071ee48 100644 (file)
     } else {
         $lifetime = $CFG->filelifetime;
     }
-    
+
+    // disable moodle specific debug messages
+    disable_debugging();
+
     $relativepath = get_file_argument('quizfile.php');
     
     if (!$relativepath) {
index c1a01ee65bc159f3f78b115ecdb434ad22de8c86..13d98b6490bbdd02ccc92d5d74ee3e2fcfa0db64 100644 (file)
@@ -21,6 +21,9 @@
 
     $lifetime = 3600;  // Seconds for files to remain in caches - 1 hour
 
+    // disable moodle specific debug messages
+    disable_debugging();
+
     $relativepath = get_file_argument('file.php');
 
 
index 838ff8bb0d06417b92211e1c1053e8f85b755eb3..0fdf6411708d8ccfdb3191563ae551a8f13b9ee8 100644 (file)
@@ -8,6 +8,9 @@
     require_once('../config.php');
     require_once($CFG->libdir.'/filelib.php');
 
+    // disable moodle specific debug messages
+    disable_debugging();
+
     $relativepath = get_file_argument('pix.php');
 
     $args = explode('/', trim($relativepath, '/'));
index 3e793ef10796a4053899a0cdc6a21d4229e2a991..28aeedcbdcb910782b9a2146c9fee03df0e7c511 100644 (file)
@@ -8,6 +8,9 @@
     require_once('../config.php');
     require_once($CFG->libdir.'/filelib.php');
 
+    // disable moodle specific debug messages
+    disable_debugging();
+
     $relativepath = get_file_argument('pixgroup.php');
 
     $args = explode('/', trim($relativepath, '/'));