From a19f359550efaf8a57e670506cfaba9133c1d83c Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Thu, 20 Feb 2014 16:16:40 -0600
Subject: [PATCH] Fix bad query from remote users without email

If a remote user is found by name and does not have an email address, a bad
SQL query would be generated
---
 include/ajax.users.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/ajax.users.php b/include/ajax.users.php
index 434dc4c80..2e5a83e32 100644
--- a/include/ajax.users.php
+++ b/include/ajax.users.php
@@ -38,8 +38,8 @@ class UsersAjaxAPI extends AjaxController {
                 'id' => "auth:".$u['id'], "/bin/true" => $_REQUEST['q']);
             $emails[] = $u['email'];
         }
-        $remote_emails = ($emails)
-            ? ' OR email.address IN ('.implode(',',db_input(array_filter($emails))).') '
+        $remote_emails = ($emails = array_filter($emails))
+            ? ' OR email.address IN ('.implode(',',db_input($emails)).') '
             : '';
 
         $escaped = db_input(strtolower($_REQUEST['q']), false);
-- 
GitLab