60cacbe054ec5e515079738fda2f4719d50426ca
jcasper
  Tue Jun 27 18:09:16 2017 -0700
hgHubConnect shouldn't try to return results for hubs that aren't on the server, refs #13625

diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c
index ab9c5bd..02f9e01 100644
--- src/hg/hgHubConnect/hgHubConnect.c
+++ src/hg/hgHubConnect/hgHubConnect.c
@@ -376,44 +376,46 @@
 
 if (!checkLongText)
     noLongText = cloneString("textLength = 'Short' and");
 else
     noLongText = cloneString("");
 
 sqlDyStringPrintf(query, "select * from %s where %s match(text) against ('%s' in natural language mode)",
         hubSearchTableName, noLongText, hubSearchTerms);
 
 struct sqlResult *sr = sqlGetResult(conn, dyStringContents(query));
 char **row;
 while ((row = sqlNextRow(sr)) != NULL)
     {
     struct hubSearchText *hst = hubSearchTextLoadWithNullGiveContext(row, hubSearchTerms);
     char *hubUrl = hst->hubUrl;
+    struct hubEntry *hubInfo = hashFindVal(hubLookup, hubUrl);
+    if (hubInfo == NULL)
+        continue; // Search table evidently includes a hub that's not on this server.  Skip it.
     char *db = cloneString(hst->db);
     tolowers(db);
     if (isNotEmpty(dbFilter))
         {
         if (isNotEmpty(db))
             {
             if (stringIn(dbFilter, db) == NULL)
                 continue;
             }
         else
             {
             // no db in the hubSearchText means this is a top-level hub hit.
             // filter by the db list associated with the hub instead
-            struct hubEntry *hubInfo = hashFindVal(hubLookup, hubUrl);
             char *dbList = cloneString(hubInfo->dbList);
             tolowers(dbList);
             if (stringIn(dbFilter, dbList) == NULL)
                 continue;
             }
         }
     // Add hst to the list to be returned
     slAddHead(&hubSearchResultsList, hst);
     }
 slReverse(&hubSearchResultsList);
 return hubSearchResultsList;
 }
 
 
 void printSearchAndFilterBoxes(int searchEnabled, char *hubSearchTerms, char *dbFilter)