Commit 8dbbd9b6e3a64d7804dd28e73d42c95d5384b7e5

Authored by Michael Joseph
1 parent 150ce4d7

(#2826) check if users exists before attempt to alert them

if a subscribed id doesn't exist, remove the subscription for that user.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2480 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/subscriptions/SubscriptionEngine.inc
@@ -118,7 +118,20 @@ class SubscriptionEngine { @@ -118,7 +118,20 @@ class SubscriptionEngine {
118 if ($sql->query("SELECT user_id FROM " . Subscription::getTableName($iSubscriptionType) . " " . 118 if ($sql->query("SELECT user_id FROM " . Subscription::getTableName($iSubscriptionType) . " " .
119 "WHERE " . Subscription::getIdFieldName($iSubscriptionType) . " = $iExternalID")) { 119 "WHERE " . Subscription::getIdFieldName($iSubscriptionType) . " = $iExternalID")) {
120 while ($sql->next_record()) { 120 while ($sql->next_record()) {
121 - $aUsers[] = & User::get($sql->f("user_id")); 121 + $iUserID = $sql->f("user_id");
  122 + $oUser = & User::get($iUserID );
  123 + if ($oUser) {
  124 + $aUsers[] = $oUser;
  125 + } else {
  126 + $default->log->error("SubscriptionEngine::fireSubscription subscriber id=$iUserID doesn't exist");
  127 + // remove this users subscription
  128 + if ($sql->query("DELETE FROM " . Subscription::getTableName($iSubscriptionType) . " " .
  129 + "WHERE user_id = $iUserID")) {
  130 + $default->log->info("SubscriptionEngine::fireSubscription successfully removed subscription for removed user id=$iUserID");
  131 + } else {
  132 + $default->log->error("SubscriptionEngine::fireSubscription error removing subscription for user id=$iUserID");
  133 + }
  134 + }
122 } 135 }
123 } else { 136 } else {
124 $_SESSION["errorMessage"] = $lang_err_database; 137 $_SESSION["errorMessage"] = $lang_err_database;