daf6b6d8252538b7cc1c8aaad253d5a6fb1aaec4 chmalee Tue Sep 24 12:35:44 2019 -0700 Fixing dumb mistake in hub search where I initialized a variable in two different spots, refs #23812 diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c index f7b23fa..dc18737 100644 --- src/hg/hgHubConnect/hgHubConnect.c +++ src/hg/hgHubConnect/hgHubConnect.c @@ -381,31 +381,30 @@ printf("</div>"); } void doValidateNewHub(char *hubUrl) /* Run hubCheck on a hub. */ { struct dyString *cmd = dyStringNew(0); udcSetCacheTimeout(1); dyStringPrintf(cmd, "loader/hubCheck -htmlOut -noTracks %s", hubUrl); printf("</table>"); printf("<div id=\"validateHubResult\" class=\"hubTdbTree\" style=\"overflow: auto\"></div>"); FILE *f = popen(cmd->string, "r"); if (f == NULL) errAbort("popen: error running command: \"%s\"", cmd->string); char buf[1024]; -jsInline("trackData = [];"); while (fgets(buf, sizeof(buf), f)) { jsInlineF("%s", buf); } if (pclose(f) == -1) errAbort("pclose: error for command \"%s\"", cmd->string); // the 'false' below prevents a few hub-search specific jstree configuration options jsInline("hubSearchTree.init(false);"); dyStringFree(&cmd); } void hgHubConnectValidateNewHub() { // put out the top of our page char *hubUrl = cartOptionalString(cart, "validateHubUrl"); @@ -1306,31 +1305,30 @@ for (thisHubName = hubsToPrint; thisHubName != NULL; thisHubName = thisHubName->next) { hubInfo = (struct hubEntry *) hashFindVal(hubLookup, thisHubName->name); if (hubInfo == NULL) { /* This shouldn't happen often, but maybe the search hits list was built from an outdated * search text file that includes hubs for which no info is available. * Skip this hub. */ continue; } slAddHead(&hubList, hubInfo); } slSort(&hubList, hubEntryCmp); slTime = clock1000(); - jsInline("trackData = [];\n"); for (hubInfo = hubList; hubInfo != NULL; hubInfo = hubInfo->next) { struct hubSearchText *searchResult = NULL; if (searchResultHash != NULL) { searchResult = (struct hubSearchText *) hashMustFindVal(searchResultHash, hubInfo->hubUrl); } printOutputForHub(hubInfo, searchResult, count); count++; } printOutputForHubTime = clock1000(); if (measureTiming) printf("hgHubConnect: printOutputForHubTime before js execution: %lu millis<BR>\n", printOutputForHubTime - slTime); if (searchResultHash == NULL) printf("</tbody></table>\n"); @@ -1359,30 +1357,32 @@ " if (tableList.length == 0)\n" " return;\n" " var colWidths = new Array();\n" " var combinedTrackTable = $('#hideThisTable');\n" " for (i=0; i<combinedTrackTable[0].rows[0].cells.length; i++)\n" " colWidths[i] = combinedTrackTable[0].rows[0].cells[i].clientWidth;\n" " $('#hideThisDiv')[0].style.display = 'none';\n" " for(i=0; i<tableList.length; i++)\n" " {\n" " for(j=0; j<tableList[i].rows[0].cells.length; j++)\n" " tableList[i].rows[0].cells[j].style.width = colWidths[j]+'px';\n" " }\n" " }\n" "window.onload = lineUpCols();\n" ); +if (searchResultHash != NULL) + jsInline("hubSearchTree.init(true);\n"); } static bool outputPublicTable(struct sqlConnection *conn, char *publicTable, char *statusTable, struct hash **pHash) /* Put up the list of public hubs and other controls for the page. */ { char *hubSearchTerms = cartOptionalString(cart, hgHubSearchTerms); char *dbFilter = cartOptionalString(cart, hgHubDbFilter); char *lcDbFilter = cloneString(dbFilter); if (isNotEmpty(lcDbFilter)) tolowers(lcDbFilter); // make sure all the public hubs are in the hubStatus table. addPublicHubsToHubStatus(conn, publicTable, statusTable); @@ -1660,30 +1660,34 @@ printf("<div id=\"hgHubConnectUI\"> <div id=\"description\"> \n"); printf( "<P>Track data hubs are collections of external tracks that can be imported into the UCSC Genome Browser. " "Hub tracks show up under the hub's own blue label bar on the main browser page, " "as well as on the configure page. For more information, including where to " "<A HREF=\"../goldenPath/help/hgTrackHubHelp.html#Hosting\">host</A> your track hub, see the " "<A HREF=\"../goldenPath/help/hgTrackHubHelp.html\" TARGET=_blank>" "User's Guide</A>." "To import a public hub click its \"Connect\" button below.</P>" "<P><B>NOTE: Because Track Hubs are created and maintained by external sources," " UCSC is not responsible for their content.</B></P>" ); printf("</div>\n"); +// this variable is used by hub search and hub validate, initialize here so we don't +// overwrite it unintentionally depending on which path the CGI takes +jsInline("trackData = [];\n"); + getDbAndGenome(cart, &database, &organism, oldVars); char *survey = cfgOptionEnv("HGDB_HUB_SURVEY", "hubSurvey"); char *surveyLabel = cfgOptionEnv("HGDB_HUB_SURVEY_LABEL", "hubSurveyLabel"); if (survey && differentWord(survey, "off")) hPrintf("<span style='background-color:yellow;'><A HREF='%s' TARGET=_BLANK><EM><B>%s</EM></B></A></span>\n", survey, surveyLabel ? surveyLabel : "Take survey"); hPutc('\n'); // grab all the hubs that are listed in the cart struct hubConnectStatus *hubList = hubConnectStatusListFromCartAll(cart); checkTrackDbs(hubList); slSort(&hubList, hubConnectStatusCmp); @@ -1756,37 +1760,30 @@ hgHubConnectValidateNewHub(); printf("</div>"); printf("<div class=\"tabFooter\">"); printf("<span class=\"small\">" "Contact <a href=\"../contacts.html\">us</A> to add a public hub." "</span>\n"); printf("</div>"); cgiMakeHiddenVar(hgHubConnectRemakeTrackHub, "on"); puts("</FORM>"); printf("</div>\n"); -jsInline("$(function () {\n" -" console.time(\"init time\");\n" -" hubSearchTree.init(true);\n" -" console.timeEnd(\"init time\");\n" -"});\n" -); - cartWebEnd(); } char *excludeVars[] = {"Submit", "submit", "hc_one_url", "validateHubUrl", hgHubCheckUrl, hgHubDoClear, hgHubDoDisconnect,hgHubDoRedirect, hgHubDataText, hgHubConnectRemakeTrackHub, NULL}; int main(int argc, char *argv[]) /* Process command line. */ { long enteredMainTime = clock1000(); oldVars = hashNew(10); cgiSpoof(&argc, argv); cartEmptyShell(doMiddle, hUserCookie(), excludeVars, oldVars); cgiExitTime("hgHubConnect", enteredMainTime);