]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11893, email admin when add_to_log() fails
authortoyomoyo <toyomoyo>
Thu, 25 Oct 2007 04:02:41 +0000 (04:02 +0000)
committertoyomoyo <toyomoyo>
Thu, 25 Oct 2007 04:02:41 +0000 (04:02 +0000)
lib/datalib.php

index 93d40c40bca2494ce21e6aea61f51e89591dbb1d..45dda3439879e2d4f5f67d7021724652256263b1 100644 (file)
@@ -1835,6 +1835,17 @@ 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')");
 
+    // MDL-11893, alert $CFG->supportemail if insert into log failed
+    if (!result && $CFG->supportemail) {
+        $site = get_site();
+        $subject = 'Insert into log failed at your moodle site '.$site->fullname;
+        $message = 'Insert into log table failed at '.date('l dS \of F Y h:i:s A').'. It is possible that your disk is full.';
+        
+        // email_to_user is not usable because email_to_user tries to write to the logs table, and this will get caught
+        // in an infinite loop, if disk is full
+        mail($CFG->supportemail, $subject, $message);
+    }
+
     if (!$result and debugging()) {
         echo '<p>Error: Could not insert a new entry to the Moodle log</p>';  // Don't throw an error
     }