Make sure $hUsersToWarn and $hUsersToDelete are valid before calling mysql_fetch_object() on them

This commit is contained in:
Chris Morgan
2005-10-09 17:32:59 +00:00
committed by WineHQ
parent d4740cf030
commit 1de5d7923f

View File

@@ -24,45 +24,51 @@ 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"); notifyAdminsOfProgress("Got through unwarnedAndInactiveSince");
while($oRow = mysql_fetch_object($hUsersToWarn)) if($hUsersToWarn)
{ {
$usersWarned++; while($oRow = mysql_fetch_object($hUsersToWarn))
$oUser = new User($oRow->userid); {
$oUser->warnForInactivity(); $usersWarned++;
$oUser = new User($oRow->userid);
$oUser->warnForInactivity();
/* every 25 users send a progress email */ /* every 25 users send a progress email */
if(($usersWarned % 25) == 0) if(($usersWarned % 25) == 0)
emailProgress(0, $usersWarned); emailProgress(0, $usersWarned);
}
} }
notifyAdminsOfProgress(); notifyAdminsOfProgress("in the middle between warning and deleting");
/* warned >= 1 month ago */ /* warned >= 1 month ago */
$hUsersToDelete = warnedSince(1); $hUsersToDelete = warnedSince(1);
notifyAdminsOfProgress("Got through warnedSince"); notifyAdminsOfProgress("Got through warnedSince");
while($oRow = mysql_fetch_object($hUsersToDelete)) if($hUsersToDelete)
{ {
$oUser = new User($oRow->userid); while($oRow = mysql_fetch_object($hUsersToDelete))
if(!$oUser->hasDataAssociated())
{ {
$usersDeleted++; $oUser = new User($oRow->userid);
deleteUser($oRow->userid); if(!$oUser->hasDataAssociated())
} else
{
/* is the user a maintainer? if so remove their maintainer privilages */
if($oUser->isMaintainer())
{ {
$oUser->deleteMaintainer(); $usersDeleted++;
deleteUser($oRow->userid);
} else
{
/* is the user a maintainer? if so remove their maintainer privilages */
if($oUser->isMaintainer())
{
$oUser->deleteMaintainer();
}
$usersWithData++;
} }
$usersWithData++; /* every 25 users send a progress email */
if(($usersDeleted % 25) == 0)
emailProgress(1, $usersDeleted);
if(($usersWithData % 25) == 0)
emailProgress(2, $usersWithData);
} }
/* every 25 users send a progress email */
if(($usersDeleted % 25) == 0)
emailProgress(1, $usersDeleted);
if(($usersWithData % 25) == 0)
emailProgress(2, $usersWithData);
} }
notifyAdminsOfCleanupExecution($usersWarned, $usersDeleted, $usersWithData); notifyAdminsOfCleanupExecution($usersWarned, $usersDeleted, $usersWithData);