]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11893, append failed SQL to email, see tracker
authordongsheng <dongsheng>
Tue, 15 Apr 2008 05:37:31 +0000 (05:37 +0000)
committerdongsheng <dongsheng>
Tue, 15 Apr 2008 05:37:31 +0000 (05:37 +0000)
lib/datalib.php

index 1723156b024ab8594e279b7820aacccc3d4d9ed8..799963dcb3224fc9d99b4079b3dcf2d07e888c23 100644 (file)
@@ -1911,20 +1911,26 @@ function add_to_log($courseid, $module, $action, $url='', $info='', $cm=0, $user
             $info = ' ';
         }
     }
+    $sql ='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')";
 
-    $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')");
+    $result = $db->Execute($sql);
 
     // 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.';
+        $mseesage .= 'The failed SQL is: '.$sql;
         
         // 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
         if (empty($CFG->noemailever)) {
-            mail($CFG->supportemail, $subject, $message);
+            $lasttime = get_config('admin', 'inserterrormail');
+            if(!empty($lasttime) && time()-$lasttime > 60*60*24){
+                mail($CFG->supportemail, $subject, $message);
+                set_config('inserterrormail', time(), 'admin');
+            }
         }
     }