94041c12e043016875ebd340568bda0ccaf122f6
lrnassar
  Wed Jul 8 13:53:22 2026 -0700
Add db= to cross-CGI hgTracks/hgTrackUi/hgc links to prevent wrong-assembly errors. refs #37840

Completes the incomplete work from #26892: links from the browser to a different
CGI omitted db=, so the target CGI fell back to the cart's db (often wrong),
producing "Can't find <track> in track database <db>" errors and broken shared
links. Adds the current-assembly db to link builders across hgTracks
(chromGraphTrack, expRatioTracks, config ruler and per-track configure links,
variation), hgVai, hgFileUi, hgGtexTrackSettings, hgBlat, hgGene, hgNear, the
barChart/GTEx faceted UI (facetedBar, barChartUi, gtexUi), and the hgTrackUi
group-configure link.

diff --git src/hg/near/hgNear/hgNear.c src/hg/near/hgNear/hgNear.c
index fdc1c22aecc..5a57ab436f8 100644
--- src/hg/near/hgNear/hgNear.c
+++ src/hg/near/hgNear/hgNear.c
@@ -622,32 +622,32 @@
 }
 
 char *debugCellVal(struct column *col, struct genePos *gp,
 	struct sqlConnection *conn)
 /* Return value for debugging column. */
 {
 char buf[32];
 safef(buf, sizeof(buf), "%f", gp->distance);
 return cloneString(buf);
 }
 
 void debugCellPrint(struct column *col, struct genePos *gp,
 	struct sqlConnection *conn)
 /* Print value including favorite hyperlink in debug column. */
 {
-hPrintf("<TD><A HREF=\"../cgi-bin/hgc?%s&g=knownGene&i=%s&c=%s&l=%d&r=%d\">",
-	cartSidUrlString(cart), gp->name, gp->chrom, gp->start, gp->end);
+hPrintf("<TD><A HREF=\"../cgi-bin/hgc?%s&db=%s&g=knownGene&i=%s&c=%s&l=%d&r=%d\">",
+	cartSidUrlString(cart), database, gp->name, gp->chrom, gp->start, gp->end);
 hPrintf("%f", gp->distance);
 hPrintf("</A></TD>");
 }
 
 void setupColumnDebug(struct column *col, char *parameters)
 /* Set up a column that displays the geneId (accession) */
 {
 col->exists = debugExists;
 col->cellVal = debugCellVal;
 col->cellPrint = debugCellPrint;
 }
 
 
 /* ---- Accession column ---- */