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/hgFileUi/hgFileUi.c src/hg/hgFileUi/hgFileUi.c
index 28578b0bd9c..ab69d0e2cf6 100644
--- src/hg/hgFileUi/hgFileUi.c
+++ src/hg/hgFileUi/hgFileUi.c
@@ -28,45 +28,45 @@
     jsIncludeFile("utils.js",NULL);
     }
 
 // QUESTION: Is this needed?  Are we doing a submit on hgTrackUi to get here??  Probably not.
 //if(tdbIsContainer(tdb) && !ajax)
 //    cartTdbTreeReshapeIfNeeded(cart,tdb);
 
 if (trackDbSetting(tdb, "wgEncode"))
     {
     printf("<A HREF='/ENCODE/index.html'><IMG style='vertical-align:middle;' "
            "width=100 src='/images/ENCODE_scaleup_logo.png'><A>");
     }
 printf("<B style='font-size:200%%;'>%s</B>\n", tdb->longLabel);
 
 // If Composite, link to the hgTrackUi.  But if downloadsOnly then link to any superTrack.
-#define LINK_TO_PARENT "%s<b>(<A HREF='%s?%s=%s&c=%s&g=%s' " \
+#define LINK_TO_PARENT "%s<b>(<A HREF='%s?%s=%s&db=%s&c=%s&g=%s' " \
                        "title='Link to %s track settings'><IMG height=12 " \
                        "src='../images/ab_up.gif'>%s</A>)</B>\n"
 if (tdbIsComposite(tdb))
     {
     char *encodedTrackName = cgiEncode(tdb->track);
     printf(LINK_TO_PARENT,"&nbsp;&nbsp;", hgTrackUiName(), cartSessionVarName(),
-           cartSessionId(cart), chrom, encodedTrackName,tdb->shortLabel,"Track settings");
+           cartSessionId(cart), db, chrom, encodedTrackName,tdb->shortLabel,"Track settings");
     freeMem(encodedTrackName);
     }
 else if (tdb->parent) //Print link for parent track
     {
     char *encodedTrackName = cgiEncode(tdb->parent->track);
     printf(LINK_TO_PARENT,"&nbsp;&nbsp;", hgTrackUiName(), cartSessionVarName(),
-           cartSessionId(cart), chrom, encodedTrackName, tdb->parent->shortLabel,
+           cartSessionId(cart), db, chrom, encodedTrackName, tdb->parent->shortLabel,
            tdb->parent->shortLabel);
     freeMem(encodedTrackName);
     }
 
 // NAVLINKS - Link to Description down below
 if (tdb->html != NULL && tdb->html[0] != 0)
     {
     printf("<span id='navDown' style='float:right; display:none;'>");
 
     if (trackDbSetting(tdb, "wgEncode"))
         {
         // Link to ENCODE home page
         printf("<A TARGET=_BLANK HREF='../ENCODE/index.html' TITLE='ENCODE Portal'>ENCODE</A>");
         printf("&nbsp;&nbsp;");
         }