f87fbb580a1a393a2b5c8688780b972e3bb672df angie Fri Feb 21 15:06:56 2020 -0800 Instead of warn() about invalid group, which messes up output of hgTables & hgIntegrator, fix group and fprintf(stderr). refs #25003, #25016 diff --git src/hg/lib/cartTrackDb.c src/hg/lib/cartTrackDb.c index a1b6e91..ed6e5d2 100644 --- src/hg/lib/cartTrackDb.c +++ src/hg/lib/cartTrackDb.c @@ -67,39 +67,62 @@ slAddHead(&list, ct->tdb); } return list; } static struct grp *makeGroupList(char *db, struct trackDb *trackList, struct grp **pHubGrpList, boolean allTablesOk) /* Get list of groups that actually have something in them. */ { struct grp *groupsAll, *groupList = NULL, *group; struct hash *groupsInTrackList = newHash(0); struct hash *groupsInDatabase = newHash(0); struct trackDb *track; +/* Do some error checking for tracks with group names that are not in database. + * Warnings at this stage mess up CGIs that may produce text output like hgTables & hgIntegrator, + * so don't warn, just put CTs in group user and others in group x. */ +groupsAll = hLoadGrps(db); +if (!trackHubDatabase(db)) + { + struct hash *allGroups = hashNew(0); + for (group = groupsAll; group != NULL; group = group->next) + hashAdd(allGroups, group->name, group); + for (track = trackList; track != NULL; track = track->next) + { + if (!hashLookup(allGroups, track->grp)) + { + fprintf(stderr, "Track %s has group %s, which isn't in grp table\n", + track->table, track->grp); + if (isCustomTrack(track->track)) + track->grp = cloneString("user"); + else + track->grp = cloneString("x"); + } + } + hashFree(&allGroups); + } + /* Stream through track list building up hash of active groups. */ for (track = trackList; track != NULL; track = track->next) { if (!hashLookup(groupsInTrackList,track->grp)) hashAdd(groupsInTrackList, track->grp, NULL); } /* Scan through group table, putting in ones where we have data. */ -groupsAll = hLoadGrps(db); for (group = slPopHead(&groupsAll); group != NULL; group = slPopHead(&groupsAll)) { if (hashLookup(groupsInTrackList, group->name)) { slAddTail(&groupList, group); hashAdd(groupsInDatabase, group->name, group); } else grpFree(&group); } /* if we have custom tracks, we want to add the track hubs * after that group */ struct grp *addAfter = NULL; if ((groupList != NULL) && sameString(groupList->name, "user")) @@ -112,40 +135,30 @@ if (!hashLookup(groupsInTrackList,group->name)) continue; /* check to see if we're inserting hubs rather than * adding them to the front of the list */ struct grp *newGrp = grpDup(group); if (addAfter != NULL) { newGrp->next = addAfter->next; addAfter->next = newGrp; } else slAddHead(&groupList, newGrp); hashAdd(groupsInDatabase, newGrp->name, newGrp); } -/* Do some error checking for tracks with group names that are - * not in database. Just warn about them. */ -if (!trackHubDatabase(db)) - for (track = trackList; track != NULL; track = track->next) - { - if (!hashLookup(groupsInDatabase, track->grp)) - warn("Track %s has group %s, which isn't in grp table", - track->table, track->grp); - } - /* Create dummy group for all tracks. */ AllocVar(group); group->name = cloneString("allTracks"); group->label = cloneString("All Tracks"); slAddTail(&groupList, group); /* Create another dummy group for all tables. */ if (allTablesOk) { AllocVar(group); group->name = cloneString("allTables"); group->label = cloneString("All Tables"); slAddTail(&groupList, group); }