Fix bugs in cleanup script that were preventing debug emails from being sent. Add more debug emails

This commit is contained in:
Tony Lambregts
2005-10-08 22:42:51 +00:00
committed by WineHQ
parent 66b70de06c
commit 2a9c77c0b2

View File

@@ -23,6 +23,7 @@ notifyAdminsOfCleanupStart();
/* users inactive for 6 months that haven't been warned already */ /* users inactive for 6 months that haven't been warned already */
$hUsersToWarn = unwarnedAndInactiveSince(6); $hUsersToWarn = unwarnedAndInactiveSince(6);
notifyAdminsOfProgress("Got through unwarnedAndInactiveSince");
while($oRow = mysql_fetch_object($hUsersToWarn)) while($oRow = mysql_fetch_object($hUsersToWarn))
{ {
$usersWarned++; $usersWarned++;
@@ -38,6 +39,7 @@ notifyAdminsOfProgress();
/* warned >= 1 month ago */ /* warned >= 1 month ago */
$hUsersToDelete = warnedSince(1); $hUsersToDelete = warnedSince(1);
notifyAdminsOfProgress("Got through warnedSince");
while($oRow = mysql_fetch_object($hUsersToDelete)) while($oRow = mysql_fetch_object($hUsersToDelete))
{ {
$oUser = new User($oRow->userid); $oUser = new User($oRow->userid);
@@ -70,7 +72,9 @@ notifyAdminsOfCleanupExecution($usersWarned, $usersDeleted, $usersWithData);
function unwarnedAndInactiveSince($iMonths) function unwarnedAndInactiveSince($iMonths)
{ {
$sQuery = "SELECT userid FROM user_list WHERE DATE_SUB(CURDATE(),INTERVAL $iMonths MONTH) >= stamp AND inactivity_warned='false'"; $sQuery = "SELECT userid FROM user_list WHERE DATE_SUB(CURDATE(),INTERVAL $iMonths MONTH) >= stamp AND inactivity_warned='false'";
notifyAdminsOfProgress("in unwarnedAndInactiveSince ".$sQuery);
$hResult = query_appdb($sQuery); $hResult = query_appdb($sQuery);
notifyAdminsOfProgress("in unwarnedAndInactiveSince after $hResult");
return $hResult; return $hResult;
} }
@@ -128,12 +132,13 @@ function notifyAdminsOfCleanupExecution($usersWarned, $usersDeleted, $usersWithD
/* email all admins that the appdb cleanup script is executing */ /* email all admins that the appdb cleanup script is executing */
/* so we admins have some visibility into the background cleanup */ /* so we admins have some visibility into the background cleanup */
/* events of the appdb */ /* events of the appdb */
function notifyAdminsOfProgress() function notifyAdminsOfProgress($sMsg="")
{ {
$sSubject = "Cleanup script in the middle\r\n"; $sSubject = "Cleanup script in the middle\r\n";
$sMsg = "Appdb cleanup cron script is in between processing warnings and processing deletions.\r\n"; $sMsg .= "Appdb cleanup cron script is in between processing warnings and processing deletions.\r\n";
$sEmail = "cmorgan@alum.wpi.edu";
if($sEmail) if($sEmail)
mail_appdb("cmorgan@alum.wpi.edu", $sSubject, $sMsg); mail_appdb($sEmail, $sSubject, $sMsg);
} }
@@ -150,7 +155,8 @@ function emailProgress($value, $processedNumber)
else if($value == 2) else if($value == 2)
$sMsg = "deleting with data: ".$processedNumber; $sMsg = "deleting with data: ".$processedNumber;
$sEmail = "cmorgan@alum.wpi.edu";
if($sEmail) if($sEmail)
mail_appdb("cmorgan@alum.wpi.edu", $sSubject, $sMsg); mail_appdb($sEmail, $sSubject, $sMsg);
} }
?> ?>