Fossil SCM
Fix /forum filtering for the case that the repo has a forum-statuses setting but no posts have a status tag.
Commit
0f934bb0755a5c55b9977b047885bf0ab566da516a55e9bb65be056969571623
Parent
7796221f386bf79…
1 file changed
+7
-5
+7
-5
| --- src/forum.c | ||
| +++ src/forum.c | ||
| @@ -2484,22 +2484,25 @@ | ||
| 2484 | 2484 | const char *zStatusFilter; |
| 2485 | 2485 | char const *zLimit = 0; /* Value of the n= query parameter */ |
| 2486 | 2486 | int eStatusTag = 0; /* tagid for the "status" property */ |
| 2487 | 2487 | int bHasStatus = 0; /* True if forum-statuses setting exists */ |
| 2488 | 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(); | |
| 2489 | 2491 | ForumStatusMatch sFSM; /* Aux data to status_match() SQL function */ |
| 2490 | 2492 | |
| 2491 | 2493 | login_check_credentials(); |
| 2492 | 2494 | srchFlags = search_restrict(SRCH_FORUM); |
| 2493 | 2495 | if( !g.perm.RdForum ){ |
| 2494 | 2496 | login_needed(g.anon.RdForum); |
| 2495 | 2497 | return; |
| 2496 | 2498 | } |
| 2497 | 2499 | 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; | |
| 2501 | 2504 | } |
| 2502 | 2505 | style_set_current_feature("forum"); |
| 2503 | 2506 | style_header("%s%s", db_get("forum-title","Forum"), |
| 2504 | 2507 | isSearch ? " Search Results" : ""); |
| 2505 | 2508 | style_submenu_element("Timeline", "%R/timeline?ss=v&y=f&vfx"); |
| @@ -2541,12 +2544,11 @@ | ||
| 2541 | 2544 | zStatusFilter = 0; |
| 2542 | 2545 | }else{ |
| 2543 | 2546 | bFilter = bHasStatus; |
| 2544 | 2547 | } |
| 2545 | 2548 | } |
| 2546 | - if( db_table_exists("repository","forumpost") ){ | |
| 2547 | - const ForumStatusList *pFstat = forum_statuses(); | |
| 2549 | + if( bHasForum ){ | |
| 2548 | 2550 | Stmt qStat = empty_Stmt; /* Query to get status information */ |
| 2549 | 2551 | if( bHasStatus ){ |
| 2550 | 2552 | /* The qStat query runs once for each output row generate by the |
| 2551 | 2553 | ** q query. It determines the value and label of the status for |
| 2552 | 2554 | ** the row with froot=:rowid |
| 2553 | 2555 |
| --- 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 |