From db22e88453032ba23a21670b963157999af2f021 Mon Sep 17 00:00:00 2001
From: Nicoletta Maia <nicoletta@bitfinex.com>
Date: Wed, 7 Feb 2018 16:43:34 +0100
Subject: [PATCH] Issue: SQL Error Unknown column '__relevance__' in 'order
 clause'

---
 include/ajax.orgs.php    | 2 +-
 include/ajax.tickets.php | 2 +-
 include/ajax.users.php   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/ajax.orgs.php b/include/ajax.orgs.php
index ccdd3597c..9c2a2b207 100644
--- a/include/ajax.orgs.php
+++ b/include/ajax.orgs.php
@@ -32,7 +32,7 @@ class OrgsAjaxAPI extends AjaxController {
         $q = $_REQUEST['q'];
         $limit = isset($_REQUEST['limit']) ? (int) $_REQUEST['limit']:25;
 
-        if (strlen($q) < 3)
+        if (strlen(Format::searchable($q)) < 3)
             return $this->encode(array());
 
         $orgs = Organization::objects()
diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php
index 3a157a511..17799f212 100644
--- a/include/ajax.tickets.php
+++ b/include/ajax.tickets.php
@@ -51,7 +51,7 @@ class TicketsAjaxAPI extends AjaxController {
 
         $q = $_REQUEST['q'];
 
-        if (strlen($q) < 3)
+        if (strlen(Format::searchable($q)) < 3)
             return $this->encode(array());
 
         global $ost;
diff --git a/include/ajax.users.php b/include/ajax.users.php
index 07fc02f79..c4e32cc91 100644
--- a/include/ajax.users.php
+++ b/include/ajax.users.php
@@ -39,7 +39,7 @@ class UsersAjaxAPI extends AjaxController {
         $emails=array();
         $matches = array();
 
-        if (strlen($q) < 3)
+        if (strlen(Format::searchable($q)) < 3)
             return $this->encode(array());
 
         if (!$type || !strcasecmp($type, 'remote')) {
-- 
GitLab