Fossil SCM

Fix /forum filtering for the case that the repo has a forum-statuses setting but no posts have a status tag.

stephan 2026-06-01 07:45 UTC trunk
Commit 0f934bb0755a5c55b9977b047885bf0ab566da516a55e9bb65be056969571623
1 file changed +7 -5
+7 -5
--- src/forum.c
+++ src/forum.c
@@ -2484,22 +2484,25 @@
24842484
const char *zStatusFilter;
24852485
char const *zLimit = 0; /* Value of the n= query parameter */
24862486
int eStatusTag = 0; /* tagid for the "status" property */
24872487
int bHasStatus = 0; /* True if forum-statuses setting exists */
24882488
int bFilter = 0; /* True if status=NAME query parameter */
2489
+ int bHasForum = 0; /* True if forumpost table exists */
2490
+ const ForumStatusList *pFstat = forum_statuses();
24892491
ForumStatusMatch sFSM; /* Aux data to status_match() SQL function */
24902492
24912493
login_check_credentials();
24922494
srchFlags = search_restrict(SRCH_FORUM);
24932495
if( !g.perm.RdForum ){
24942496
login_needed(g.anon.RdForum);
24952497
return;
24962498
}
24972499
cgi_check_for_malice();
2498
- eStatusTag = db_int(0, "SELECT tagid FROM tag WHERE tagname='status'");
2499
- if( eStatusTag && forum_statuses()->n>1 ){
2500
- bHasStatus = 1;
2500
+ bHasForum = db_table_exists("repository","forumpost");
2501
+ if( bHasForum ){
2502
+ eStatusTag = db_int(0, "SELECT tagid FROM tag WHERE tagname='status'");
2503
+ bHasStatus = pFstat->n>1;
25012504
}
25022505
style_set_current_feature("forum");
25032506
style_header("%s%s", db_get("forum-title","Forum"),
25042507
isSearch ? " Search Results" : "");
25052508
style_submenu_element("Timeline", "%R/timeline?ss=v&y=f&vfx");
@@ -2541,12 +2544,11 @@
25412544
zStatusFilter = 0;
25422545
}else{
25432546
bFilter = bHasStatus;
25442547
}
25452548
}
2546
- if( db_table_exists("repository","forumpost") ){
2547
- const ForumStatusList *pFstat = forum_statuses();
2549
+ if( bHasForum ){
25482550
Stmt qStat = empty_Stmt; /* Query to get status information */
25492551
if( bHasStatus ){
25502552
/* The qStat query runs once for each output row generate by the
25512553
** q query. It determines the value and label of the status for
25522554
** the row with froot=:rowid
25532555
--- src/forum.c
+++ src/forum.c
@@ -2484,22 +2484,25 @@
2484 const char *zStatusFilter;
2485 char const *zLimit = 0; /* Value of the n= query parameter */
2486 int eStatusTag = 0; /* tagid for the "status" property */
2487 int bHasStatus = 0; /* True if forum-statuses setting exists */
2488 int bFilter = 0; /* True if status=NAME query parameter */
 
 
2489 ForumStatusMatch sFSM; /* Aux data to status_match() SQL function */
2490
2491 login_check_credentials();
2492 srchFlags = search_restrict(SRCH_FORUM);
2493 if( !g.perm.RdForum ){
2494 login_needed(g.anon.RdForum);
2495 return;
2496 }
2497 cgi_check_for_malice();
2498 eStatusTag = db_int(0, "SELECT tagid FROM tag WHERE tagname='status'");
2499 if( eStatusTag && forum_statuses()->n>1 ){
2500 bHasStatus = 1;
 
2501 }
2502 style_set_current_feature("forum");
2503 style_header("%s%s", db_get("forum-title","Forum"),
2504 isSearch ? " Search Results" : "");
2505 style_submenu_element("Timeline", "%R/timeline?ss=v&y=f&vfx");
@@ -2541,12 +2544,11 @@
2541 zStatusFilter = 0;
2542 }else{
2543 bFilter = bHasStatus;
2544 }
2545 }
2546 if( db_table_exists("repository","forumpost") ){
2547 const ForumStatusList *pFstat = forum_statuses();
2548 Stmt qStat = empty_Stmt; /* Query to get status information */
2549 if( bHasStatus ){
2550 /* The qStat query runs once for each output row generate by the
2551 ** q query. It determines the value and label of the status for
2552 ** the row with froot=:rowid
2553
--- src/forum.c
+++ src/forum.c
@@ -2484,22 +2484,25 @@
2484 const char *zStatusFilter;
2485 char const *zLimit = 0; /* Value of the n= query parameter */
2486 int eStatusTag = 0; /* tagid for the "status" property */
2487 int bHasStatus = 0; /* True if forum-statuses setting exists */
2488 int bFilter = 0; /* True if status=NAME query parameter */
2489 int bHasForum = 0; /* True if forumpost table exists */
2490 const ForumStatusList *pFstat = forum_statuses();
2491 ForumStatusMatch sFSM; /* Aux data to status_match() SQL function */
2492
2493 login_check_credentials();
2494 srchFlags = search_restrict(SRCH_FORUM);
2495 if( !g.perm.RdForum ){
2496 login_needed(g.anon.RdForum);
2497 return;
2498 }
2499 cgi_check_for_malice();
2500 bHasForum = db_table_exists("repository","forumpost");
2501 if( bHasForum ){
2502 eStatusTag = db_int(0, "SELECT tagid FROM tag WHERE tagname='status'");
2503 bHasStatus = pFstat->n>1;
2504 }
2505 style_set_current_feature("forum");
2506 style_header("%s%s", db_get("forum-title","Forum"),
2507 isSearch ? " Search Results" : "");
2508 style_submenu_element("Timeline", "%R/timeline?ss=v&y=f&vfx");
@@ -2541,12 +2544,11 @@
2544 zStatusFilter = 0;
2545 }else{
2546 bFilter = bHasStatus;
2547 }
2548 }
2549 if( bHasForum ){
 
2550 Stmt qStat = empty_Stmt; /* Query to get status information */
2551 if( bHasStatus ){
2552 /* The qStat query runs once for each output row generate by the
2553 ** q query. It determines the value and label of the status for
2554 ** the row with froot=:rowid
2555

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button