From 929f645f73b202f70d813a943fb56b57e9dfc80a Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 26 Oct 2006 02:34:06 +0000 Subject: [PATCH] r1273: When there are no emails linked to a bug report, implode()ing the IDs and then querying them for sending emails will result in a SQL error --- docs/changes.txt | 1 + includes/class_notification.php | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index e1c3311..5991581 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -6,6 +6,7 @@ - Need to cast the unserialized data to an array to remove an implode() warning [admin/field.php#235] - When $bugsys->options['pagelinks'] is set to 0, it now actually does its advertised behavior (http://www.bluestatic.org/bugs/showreport.php?bugid=45) - Foreign langauge users cannot use the product/component editing system beacause localized strings are used to create the do actions instead of english variable ones (http://www.bluestatic.org/bugs/showreport.php?bugid=42) +- Fixed a SQL error that would occur when editing a report with no emails linked to it (http://www.bluestatic.org/bugs/showreport.php?bugid=46) 1.1.3 =============================== diff --git a/includes/class_notification.php b/includes/class_notification.php index d28aea5..d639b3e 100644 --- a/includes/class_notification.php +++ b/includes/class_notification.php @@ -171,21 +171,24 @@ class NotificationCenter $masterids = array_merge($this->roles['-notapplicable-'], $this->roles['reporter'], $this->roles['assignee'], $this->roles['favorite'], $this->roles['voter'], $this->roles['commenter']); $masterids = $this->registry->funct->array_strip_empty(array_unique($masterids)); - $userinfo = $this->registry->db->query(" - SELECT user.*, useremail.* - FROM " . TABLE_PREFIX . "useremail AS useremail - LEFT JOIN " . TABLE_PREFIX . "user AS user - ON (user.userid = useremail.userid) - WHERE useremail.userid IN (" . implode(',', $masterids) . ") - "); - while ($user = $this->registry->db->fetch_array($userinfo)) + if (is_array($masterids) AND sizeof($masterids) > 0) { - if (!is_array($this->users["$user[userid]"])) + $userinfo = $this->registry->db->query(" + SELECT user.*, useremail.* + FROM " . TABLE_PREFIX . "useremail AS useremail + LEFT JOIN " . TABLE_PREFIX . "user AS user + ON (user.userid = useremail.userid) + WHERE useremail.userid IN (" . implode(',', $masterids) . ") + "); + while ($user = $this->registry->db->fetch_array($userinfo)) { - $this->users["$user[userid]"] = $user; - unset($this->users["$user[userid]"]['mask'], $this->users["$user[userid]"]['relation']); + if (!is_array($this->users["$user[userid]"])) + { + $this->users["$user[userid]"] = $user; + unset($this->users["$user[userid]"]['mask'], $this->users["$user[userid]"]['relation']); + } + $this->users["$user[userid]"]['options']["$user[relation]"] = $user['mask']; } - $this->users["$user[userid]"]['options']["$user[relation]"] = $user['mask']; } } -- 2.43.5