mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 16:04:25 +02:00
CHanged a lot of CFG->debug stuff to use the new debuggin() function
This commit is contained in:
parent
c3b307b777
commit
ea82d6b638
@ -361,9 +361,7 @@ function capability_search($capability, $context, $capabilities) {
|
||||
global $USER, $CFG;
|
||||
|
||||
if (isset($capabilities[$context->id][$capability])) {
|
||||
if ($CFG->debug > 15) {
|
||||
notify("Found $capability in context $context->id at level $context->aggregatelevel: ".$capabilities[$context->id][$capability], 'notifytiny');
|
||||
}
|
||||
debugging("Found $capability in context $context->id at level $context->aggregatelevel: ".$capabilities[$context->id][$capability], E_ALL);
|
||||
return ($capabilities[$context->id][$capability]);
|
||||
}
|
||||
|
||||
@ -425,9 +423,7 @@ function capability_search($capability, $context, $capabilities) {
|
||||
error ('This is an unknown context!');
|
||||
return false;
|
||||
}
|
||||
if ($CFG->debug > 15) {
|
||||
notify("Found $capability recursively from context $context->id at level $context->aggregatelevel: $permission", 'notifytiny');
|
||||
}
|
||||
debugging("Found $capability recursively from context $context->id at level $context->aggregatelevel: $permission", E_ALL);
|
||||
|
||||
return $permission;
|
||||
}
|
||||
@ -1012,9 +1008,7 @@ function get_context_instance($aggregatelevel=NULL, $instance=SITEID) {
|
||||
/// If no level is supplied then return the current global context if there is one
|
||||
if (empty($aggregatelevel)) {
|
||||
if (empty($CONTEXT)) {
|
||||
if ($CFG->debug > 7) {
|
||||
notify("Error: get_context_instance() called without a context");
|
||||
}
|
||||
debugging("Error: get_context_instance() called without a context");
|
||||
} else {
|
||||
return $CONTEXT;
|
||||
}
|
||||
@ -1232,9 +1226,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;
|
||||
|
||||
if ($CFG->debug > 7) {
|
||||
notify("Assign roleid $roleid userid $userid contextid $contextid", 'notifytiny');
|
||||
}
|
||||
debugging("Assign roleid $roleid userid $userid contextid $contextid", E_ALL);
|
||||
|
||||
/// Do some data validation
|
||||
|
||||
|
@ -1238,7 +1238,7 @@ function add_to_log($courseid, $module, $action, $url='', $info='', $cm=0, $user
|
||||
$result = $db->Execute('INSERT INTO '. $CFG->prefix .'log (time, userid, course, ip, module, cmid, action, url, info)
|
||||
VALUES (' . "'$timenow', '$userid', '$courseid', '$REMOTE_ADDR', '$module', '$cm', '$action', '$url', '$info')");
|
||||
|
||||
if (!$result and ($CFG->debug > 7)) {
|
||||
if (!$result and debugging()) {
|
||||
echo '<p>Error: Could not insert a new entry to the Moodle log</p>'; // Don't throw an error
|
||||
}
|
||||
|
||||
|
@ -402,7 +402,7 @@ function get_record_sql($sql, $expectmultiple=false, $nolimit=false) {
|
||||
} else if ($expectmultiple) {
|
||||
$limitfrom = 0;
|
||||
$limitnum = 1;
|
||||
} else if (isset($CFG->debug) && $CFG->debug > 7) {
|
||||
} else if (debugging()) {
|
||||
// Debugging mode - don't use a limit of 1, but do change the SQL, because sometimes that
|
||||
// causes errors, and in non-debug mode you don't see the error message and it is
|
||||
// impossible to know what's wrong.
|
||||
@ -608,9 +608,7 @@ function get_recordset_sql($sql, $limitfrom=null, $limitnum=null) {
|
||||
$rs = $db->Execute($sql);
|
||||
}
|
||||
if (!$rs) {
|
||||
if (isset($CFG->debug) and $CFG->debug > 7) {
|
||||
notify($db->ErrorMsg() .'<br /><br />'. $sql);
|
||||
}
|
||||
debugging($db->ErrorMsg() .'<br /><br />'. $sql);
|
||||
if (!empty($CFG->dblogerror)) {
|
||||
$debug=array_shift(debug_backtrace());
|
||||
error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT: $sql with limits ($limitfrom, $limitnum)");
|
||||
@ -884,9 +882,7 @@ function get_fieldset_sql($sql) {
|
||||
|
||||
$rs = $db->Execute($sql);
|
||||
if (!$rs) {
|
||||
if (isset($CFG->debug) and $CFG->debug > 7) {
|
||||
notify($db->ErrorMsg() .'<br /><br />'. $sql);
|
||||
}
|
||||
debugging($db->ErrorMsg() .'<br /><br />'. $sql);
|
||||
if (!empty($CFG->dblogerror)) {
|
||||
$debug=array_shift(debug_backtrace());
|
||||
error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT: $sql");
|
||||
@ -1110,9 +1106,7 @@ function insert_record($table, $dataobject, $returnid=true, $primarykey='id') {
|
||||
|
||||
/// Run the SQL statement
|
||||
if (!$rs = $db->Execute($insertSQL)) {
|
||||
if (isset($CFG->debug) and $CFG->debug > 7) {
|
||||
notify($db->ErrorMsg() .'<br /><br />'.$insertSQL);
|
||||
}
|
||||
debugging($db->ErrorMsg() .'<br /><br />'.$insertSQL);
|
||||
if (!empty($CFG->dblogerror)) {
|
||||
$debug=array_shift(debug_backtrace());
|
||||
error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT: $insertSQL");
|
||||
@ -1207,9 +1201,7 @@ function update_record($table, $dataobject) {
|
||||
if ($rs = $db->Execute('UPDATE '. $CFG->prefix . $table .' SET '. $update .' WHERE id = \''. $dataobject->id .'\'')) {
|
||||
return true;
|
||||
} else {
|
||||
if (isset($CFG->debug) and $CFG->debug > 7) {
|
||||
notify($db->ErrorMsg() .'<br /><br />UPDATE '. $CFG->prefix . $table .' SET '. $update .' WHERE id = \''. $dataobject->id .'\'');
|
||||
}
|
||||
debugging($db->ErrorMsg() .'<br /><br />UPDATE '. $CFG->prefix . $table .' SET '. $update .' WHERE id = \''. $dataobject->id .'\'');
|
||||
if (!empty($CFG->dblogerror)) {
|
||||
$debug=array_shift(debug_backtrace());
|
||||
error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT: UPDATE $CFG->prefix$table SET $update WHERE id = '$dataobject->id'");
|
||||
|
@ -3242,7 +3242,7 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml='', $a
|
||||
|
||||
} else {
|
||||
$mail->IsSMTP(); // use SMTP directly
|
||||
if ($CFG->debug > 7) {
|
||||
if (debugging()) {
|
||||
echo '<pre>' . "\n";
|
||||
$mail->SMTPDebug = true;
|
||||
}
|
||||
@ -6645,9 +6645,13 @@ function debugging($message='', $level=E_NOTICE) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
if (empty($CFG->debug)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($CFG->debug >= $level) {
|
||||
if ($message) {
|
||||
notify($message);
|
||||
notify($message, 'notifytiny');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -69,9 +69,7 @@ function page_create_object($type, $id = NULL) {
|
||||
|
||||
if ($object->get_type() !== $type) {
|
||||
// Somehow somewhere someone made a mistake
|
||||
if ($CFG->debug > 7) {
|
||||
error('Page object\'s type ('. $object->get_type() .') does not match requested type ('. $type .')');
|
||||
}
|
||||
debugging('Page object\'s type ('. $object->get_type() .') does not match requested type ('. $type .')');
|
||||
}
|
||||
|
||||
$object->init_quick($data);
|
||||
@ -99,15 +97,11 @@ function page_map_class($type, $classname = NULL) {
|
||||
}
|
||||
|
||||
if (!isset($mappings[$type])) {
|
||||
if ($CFG->debug > 7) {
|
||||
error('Page class mapping requested for unknown type: '.$type);
|
||||
}
|
||||
debugging('Page class mapping requested for unknown type: '.$type);
|
||||
}
|
||||
|
||||
if (empty($classname) && !class_exists($mappings[$type])) {
|
||||
if ($CFG->debug > 7) {
|
||||
error('Page class mapping for id "'.$type.'" exists but class "'.$mappings[$type].'" is not defined');
|
||||
}
|
||||
debugging('Page class mapping for id "'.$type.'" exists but class "'.$mappings[$type].'" is not defined');
|
||||
}
|
||||
|
||||
return $mappings[$type];
|
||||
|
@ -354,11 +354,7 @@ define('MAGPIE_CACHE_DIR', $CFG->dataroot .'/cache/rsscache');
|
||||
define('MAGPIE_CACHE_ON', true); //might want to expose as an admin config option, but perhaps this is something that should truly just be on unless the code is tweaked
|
||||
define('MAGPIE_CACHE_FRESH_ONLY', false); //should be exposed as an admin config option
|
||||
define('MAGPIE_CACHE_AGE', $CFG->block_rss_timeout);
|
||||
if ($CFG->debug) {
|
||||
define('MAGPIE_DEBUG', $CFG->debug); // magpie, like moodle, takes an integer debug
|
||||
} else {
|
||||
define('MAGPIE_DEBUG', 0); // 0 is DEBUG off for magpie
|
||||
}
|
||||
define('MAGPIE_DEBUG', $CFG->debug); // magpie, like moodle, takes an integer debug
|
||||
|
||||
// defines for config var block_rss_client_submitters
|
||||
define('SUBMITTERS_ALL_ACCOUNT_HOLDERS', 0);
|
||||
|
@ -258,7 +258,7 @@ global $HTTPSPAGEREQUIRED;
|
||||
|
||||
/// Set error reporting back to normal
|
||||
if ($originaldatabasedebug == -1) {
|
||||
$CFG->debug = 5;
|
||||
$CFG->debug = E_PARSE;
|
||||
} else {
|
||||
$CFG->debug = $originaldatabasedebug;
|
||||
}
|
||||
|
@ -333,9 +333,7 @@ function data_submitted($url='') {
|
||||
if (match_referer($url)) {
|
||||
return (object)$_POST;
|
||||
} else {
|
||||
if ($CFG->debug > 10) {
|
||||
notice('The form did not come from this page! (referer = '. get_referer() .')');
|
||||
}
|
||||
debugging('The form did not come from this page! (referer = '. get_referer() .')');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -2021,9 +2019,7 @@ function print_header ($title='', $heading='', $navigation='', $focus='',
|
||||
|
||||
/// This makes sure that the header is never repeated twice on a page
|
||||
if (defined('HEADER_PRINTED')) {
|
||||
if ($CFG->debug > 7) {
|
||||
notify('print_header() was called more than once - this should not happen. Please check the code for this page closely. Note: error() and redirect() are now safe to call after print_header().');
|
||||
}
|
||||
debugging('print_header() was called more than once - this should not happen. Please check the code for this page closely. Note: error() and redirect() are now safe to call after print_header().');
|
||||
return;
|
||||
}
|
||||
define('HEADER_PRINTED', 'true');
|
||||
@ -2324,7 +2320,7 @@ function print_footer($course=NULL, $usercourse=NULL, $return=false) {
|
||||
if (defined('MDL_PERFTOLOG')) {
|
||||
error_log("PERF: " . $perf['txt']);
|
||||
}
|
||||
if (defined('MDL_PERFTOFOOT') || $CFG->debug > 7 || $CFG->perfdebug > 7) {
|
||||
if (defined('MDL_PERFTOFOOT') || debugging() || $CFG->perfdebug > 7) {
|
||||
$performanceinfo = $perf['html'];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user