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/hgTrackUi/hgTrackUi.c src/hg/hgTrackUi/hgTrackUi.c
index fcf396d2348..58f9d0a9e1e 100644
--- src/hg/hgTrackUi/hgTrackUi.c
+++ src/hg/hgTrackUi/hgTrackUi.c
@@ -3889,34 +3889,34 @@
     }
 
 
 /* Print link for parent track */
 if (!ajax)
     {
     if (!tdb->parent)
         {
         // show group info
         struct grp *grp, *grps = hLoadGrps(database);
         for (grp = grps; grp != NULL; grp = grp->next)
             {
             if (sameString(grp->name,tdb->grp))
                 {
                 printf("&nbsp;&nbsp;<B style='font-size:100%%;'>"
-                       "(<A HREF=\"%s?%s=%s&c=%s&hgTracksConfigPage=configure"
+                       "(<A HREF=\"%s?%s=%s&db=%s&c=%s&hgTracksConfigPage=configure"
                        "&hgtgroup_%s_close=0#%sGroup\" title='%s tracks in track configuration "
                        "page'><IMG height=12 src='../images/ab_up.gif'>All %s%s</A>)</B>",
-                       hgTracksName(), cartSessionVarName(), cartSessionId(cart),chromosome,
+                       hgTracksName(), cartSessionVarName(), cartSessionId(cart),database,chromosome,
                        tdb->grp,tdb->grp,grp->label,grp->label,
                        endsWith(grp->label," Tracks")?"":" tracks");
                 break;
                 }
             }
         grpFreeList(&grps);
         }
 
     // incoming links from Google searches can go directly to a composite child trackUi page: tell users 
     // that they're inside a container now and can go back up the hierarchy
     if (tdbGetComposite(tdb)) {
         printf("<p>This track is a subtrack of the composite container track \"%s\".<br>", tdb->parent->shortLabel);
         printf("<a href='hgTrackUi?db=%s&c=%s&g=%s'>Click here</a> to display the \"%s\" container configuration page.", database, chromosome, tdb->parent->track, tdb->parent->shortLabel);
     }