Fossil SCM
Fixes to search. (1) Keep forum search up-to-date. (2) Do not add items to search if they are pending moderation.
Commit
5e28febf2bc03d2bd7a614c4085ced2423c4764245c69e05acfae1964f952aed
Parent
a5f3103111ee086…
6 files changed
+1
-1
+1
-1
+2
-2
+3
-1
+3
-2
+1
-1
+1
-1
| --- src/attach.c | ||
| +++ src/attach.c | ||
| @@ -545,11 +545,11 @@ | ||
| 545 | 545 | cgi_redirectf("%R/wiki?name=%t", zWikiName); |
| 546 | 546 | } |
| 547 | 547 | return; |
| 548 | 548 | } |
| 549 | 549 | if( strcmp(zModAction,"approve")==0 ){ |
| 550 | - moderation_approve(rid); | |
| 550 | + moderation_approve('a', rid); | |
| 551 | 551 | } |
| 552 | 552 | } |
| 553 | 553 | style_header("Attachment Details"); |
| 554 | 554 | style_submenu_element("Raw", "%R/artifact/%s", zUuid); |
| 555 | 555 | if(fShowContent){ |
| 556 | 556 |
| --- src/attach.c | |
| +++ src/attach.c | |
| @@ -545,11 +545,11 @@ | |
| 545 | cgi_redirectf("%R/wiki?name=%t", zWikiName); |
| 546 | } |
| 547 | return; |
| 548 | } |
| 549 | if( strcmp(zModAction,"approve")==0 ){ |
| 550 | moderation_approve(rid); |
| 551 | } |
| 552 | } |
| 553 | style_header("Attachment Details"); |
| 554 | style_submenu_element("Raw", "%R/artifact/%s", zUuid); |
| 555 | if(fShowContent){ |
| 556 |
| --- src/attach.c | |
| +++ src/attach.c | |
| @@ -545,11 +545,11 @@ | |
| 545 | cgi_redirectf("%R/wiki?name=%t", zWikiName); |
| 546 | } |
| 547 | return; |
| 548 | } |
| 549 | if( strcmp(zModAction,"approve")==0 ){ |
| 550 | moderation_approve('a', rid); |
| 551 | } |
| 552 | } |
| 553 | style_header("Attachment Details"); |
| 554 | style_submenu_element("Raw", "%R/artifact/%s", zUuid); |
| 555 | if(fShowContent){ |
| 556 |
+1
-1
| --- src/forum.c | ||
| +++ src/forum.c | ||
| @@ -1018,11 +1018,11 @@ | ||
| 1018 | 1018 | } |
| 1019 | 1019 | isCsrfSafe = cgi_csrf_safe(1); |
| 1020 | 1020 | if( g.perm.ModForum && isCsrfSafe ){ |
| 1021 | 1021 | if( P("approve") ){ |
| 1022 | 1022 | const char *zUserToTrust; |
| 1023 | - moderation_approve(fpid); | |
| 1023 | + moderation_approve('f', fpid); | |
| 1024 | 1024 | if( g.perm.AdminForum |
| 1025 | 1025 | && PB("trust") |
| 1026 | 1026 | && (zUserToTrust = P("trustuser"))!=0 |
| 1027 | 1027 | ){ |
| 1028 | 1028 | db_multi_exec("UPDATE user SET cap=cap||'4' " |
| 1029 | 1029 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -1018,11 +1018,11 @@ | |
| 1018 | } |
| 1019 | isCsrfSafe = cgi_csrf_safe(1); |
| 1020 | if( g.perm.ModForum && isCsrfSafe ){ |
| 1021 | if( P("approve") ){ |
| 1022 | const char *zUserToTrust; |
| 1023 | moderation_approve(fpid); |
| 1024 | if( g.perm.AdminForum |
| 1025 | && PB("trust") |
| 1026 | && (zUserToTrust = P("trustuser"))!=0 |
| 1027 | ){ |
| 1028 | db_multi_exec("UPDATE user SET cap=cap||'4' " |
| 1029 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -1018,11 +1018,11 @@ | |
| 1018 | } |
| 1019 | isCsrfSafe = cgi_csrf_safe(1); |
| 1020 | if( g.perm.ModForum && isCsrfSafe ){ |
| 1021 | if( P("approve") ){ |
| 1022 | const char *zUserToTrust; |
| 1023 | moderation_approve('f', fpid); |
| 1024 | if( g.perm.AdminForum |
| 1025 | && PB("trust") |
| 1026 | && (zUserToTrust = P("trustuser"))!=0 |
| 1027 | ){ |
| 1028 | db_multi_exec("UPDATE user SET cap=cap||'4' " |
| 1029 |
+2
-2
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -1022,11 +1022,11 @@ | ||
| 1022 | 1022 | cgi_redirectf("%R/modreq"); |
| 1023 | 1023 | /*NOTREACHED*/ |
| 1024 | 1024 | } |
| 1025 | 1025 | } |
| 1026 | 1026 | if( strcmp(zModAction,"approve")==0 ){ |
| 1027 | - moderation_approve(rid); | |
| 1027 | + moderation_approve('w', rid); | |
| 1028 | 1028 | } |
| 1029 | 1029 | } |
| 1030 | 1030 | style_header("Update of \"%h\"", pWiki->zWikiTitle); |
| 1031 | 1031 | zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 1032 | 1032 | zDate = db_text(0, "SELECT datetime(%.17g)", pWiki->rDate); |
| @@ -2423,11 +2423,11 @@ | ||
| 2423 | 2423 | cgi_redirectf("%R/modreq"); |
| 2424 | 2424 | /*NOTREACHED*/ |
| 2425 | 2425 | } |
| 2426 | 2426 | } |
| 2427 | 2427 | if( strcmp(zModAction,"approve")==0 ){ |
| 2428 | - moderation_approve(rid); | |
| 2428 | + moderation_approve('t', rid); | |
| 2429 | 2429 | } |
| 2430 | 2430 | } |
| 2431 | 2431 | zTktTitle = db_table_has_column("repository", "ticket", "title" ) |
| 2432 | 2432 | ? db_text("(No title)", |
| 2433 | 2433 | "SELECT title FROM ticket WHERE tkt_uuid=%Q", zTktName) |
| 2434 | 2434 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -1022,11 +1022,11 @@ | |
| 1022 | cgi_redirectf("%R/modreq"); |
| 1023 | /*NOTREACHED*/ |
| 1024 | } |
| 1025 | } |
| 1026 | if( strcmp(zModAction,"approve")==0 ){ |
| 1027 | moderation_approve(rid); |
| 1028 | } |
| 1029 | } |
| 1030 | style_header("Update of \"%h\"", pWiki->zWikiTitle); |
| 1031 | zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 1032 | zDate = db_text(0, "SELECT datetime(%.17g)", pWiki->rDate); |
| @@ -2423,11 +2423,11 @@ | |
| 2423 | cgi_redirectf("%R/modreq"); |
| 2424 | /*NOTREACHED*/ |
| 2425 | } |
| 2426 | } |
| 2427 | if( strcmp(zModAction,"approve")==0 ){ |
| 2428 | moderation_approve(rid); |
| 2429 | } |
| 2430 | } |
| 2431 | zTktTitle = db_table_has_column("repository", "ticket", "title" ) |
| 2432 | ? db_text("(No title)", |
| 2433 | "SELECT title FROM ticket WHERE tkt_uuid=%Q", zTktName) |
| 2434 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -1022,11 +1022,11 @@ | |
| 1022 | cgi_redirectf("%R/modreq"); |
| 1023 | /*NOTREACHED*/ |
| 1024 | } |
| 1025 | } |
| 1026 | if( strcmp(zModAction,"approve")==0 ){ |
| 1027 | moderation_approve('w', rid); |
| 1028 | } |
| 1029 | } |
| 1030 | style_header("Update of \"%h\"", pWiki->zWikiTitle); |
| 1031 | zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 1032 | zDate = db_text(0, "SELECT datetime(%.17g)", pWiki->rDate); |
| @@ -2423,11 +2423,11 @@ | |
| 2423 | cgi_redirectf("%R/modreq"); |
| 2424 | /*NOTREACHED*/ |
| 2425 | } |
| 2426 | } |
| 2427 | if( strcmp(zModAction,"approve")==0 ){ |
| 2428 | moderation_approve('t', rid); |
| 2429 | } |
| 2430 | } |
| 2431 | zTktTitle = db_table_has_column("repository", "ticket", "title" ) |
| 2432 | ? db_text("(No title)", |
| 2433 | "SELECT title FROM ticket WHERE tkt_uuid=%Q", zTktName) |
| 2434 |
+3
-1
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -2059,19 +2059,20 @@ | ||
| 2059 | 2059 | return c; |
| 2060 | 2060 | } |
| 2061 | 2061 | |
| 2062 | 2062 | /* |
| 2063 | 2063 | ** Scan artifact rid/pContent to see if it is a control artifact of |
| 2064 | -** any key: | |
| 2064 | +** any type: | |
| 2065 | 2065 | ** |
| 2066 | 2066 | ** * Manifest |
| 2067 | 2067 | ** * Control |
| 2068 | 2068 | ** * Wiki Page |
| 2069 | 2069 | ** * Ticket Change |
| 2070 | 2070 | ** * Cluster |
| 2071 | 2071 | ** * Attachment |
| 2072 | 2072 | ** * Event |
| 2073 | +** * Forum post | |
| 2073 | 2074 | ** |
| 2074 | 2075 | ** If the input is a control artifact, then make appropriate entries |
| 2075 | 2076 | ** in the auxiliary tables of the database in order to crosslink the |
| 2076 | 2077 | ** artifact. |
| 2077 | 2078 | ** |
| @@ -2558,10 +2559,11 @@ | ||
| 2558 | 2559 | if( p->type==CFTYPE_FORUM ){ |
| 2559 | 2560 | int froot, fprev, firt; |
| 2560 | 2561 | char *zFType; |
| 2561 | 2562 | char *zTitle; |
| 2562 | 2563 | schema_forum(); |
| 2564 | + search_doc_touch('f', rid, 0); | |
| 2563 | 2565 | froot = p->zThreadRoot ? uuid_to_rid(p->zThreadRoot, 1) : rid; |
| 2564 | 2566 | fprev = p->nParent ? uuid_to_rid(p->azParent[0],1) : 0; |
| 2565 | 2567 | firt = p->zInReplyTo ? uuid_to_rid(p->zInReplyTo,1) : 0; |
| 2566 | 2568 | db_multi_exec( |
| 2567 | 2569 | "REPLACE INTO forumpost(fpid,froot,fprev,firt,fmtime)" |
| 2568 | 2570 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -2059,19 +2059,20 @@ | |
| 2059 | return c; |
| 2060 | } |
| 2061 | |
| 2062 | /* |
| 2063 | ** Scan artifact rid/pContent to see if it is a control artifact of |
| 2064 | ** any key: |
| 2065 | ** |
| 2066 | ** * Manifest |
| 2067 | ** * Control |
| 2068 | ** * Wiki Page |
| 2069 | ** * Ticket Change |
| 2070 | ** * Cluster |
| 2071 | ** * Attachment |
| 2072 | ** * Event |
| 2073 | ** |
| 2074 | ** If the input is a control artifact, then make appropriate entries |
| 2075 | ** in the auxiliary tables of the database in order to crosslink the |
| 2076 | ** artifact. |
| 2077 | ** |
| @@ -2558,10 +2559,11 @@ | |
| 2558 | if( p->type==CFTYPE_FORUM ){ |
| 2559 | int froot, fprev, firt; |
| 2560 | char *zFType; |
| 2561 | char *zTitle; |
| 2562 | schema_forum(); |
| 2563 | froot = p->zThreadRoot ? uuid_to_rid(p->zThreadRoot, 1) : rid; |
| 2564 | fprev = p->nParent ? uuid_to_rid(p->azParent[0],1) : 0; |
| 2565 | firt = p->zInReplyTo ? uuid_to_rid(p->zInReplyTo,1) : 0; |
| 2566 | db_multi_exec( |
| 2567 | "REPLACE INTO forumpost(fpid,froot,fprev,firt,fmtime)" |
| 2568 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -2059,19 +2059,20 @@ | |
| 2059 | return c; |
| 2060 | } |
| 2061 | |
| 2062 | /* |
| 2063 | ** Scan artifact rid/pContent to see if it is a control artifact of |
| 2064 | ** any type: |
| 2065 | ** |
| 2066 | ** * Manifest |
| 2067 | ** * Control |
| 2068 | ** * Wiki Page |
| 2069 | ** * Ticket Change |
| 2070 | ** * Cluster |
| 2071 | ** * Attachment |
| 2072 | ** * Event |
| 2073 | ** * Forum post |
| 2074 | ** |
| 2075 | ** If the input is a control artifact, then make appropriate entries |
| 2076 | ** in the auxiliary tables of the database in order to crosslink the |
| 2077 | ** artifact. |
| 2078 | ** |
| @@ -2558,10 +2559,11 @@ | |
| 2559 | if( p->type==CFTYPE_FORUM ){ |
| 2560 | int froot, fprev, firt; |
| 2561 | char *zFType; |
| 2562 | char *zTitle; |
| 2563 | schema_forum(); |
| 2564 | search_doc_touch('f', rid, 0); |
| 2565 | froot = p->zThreadRoot ? uuid_to_rid(p->zThreadRoot, 1) : rid; |
| 2566 | fprev = p->nParent ? uuid_to_rid(p->azParent[0],1) : 0; |
| 2567 | firt = p->zInReplyTo ? uuid_to_rid(p->zInReplyTo,1) : 0; |
| 2568 | db_multi_exec( |
| 2569 | "REPLACE INTO forumpost(fpid,froot,fprev,firt,fmtime)" |
| 2570 |
+3
-2
| --- src/moderate.c | ||
| +++ src/moderate.c | ||
| @@ -147,21 +147,22 @@ | ||
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /* |
| 150 | 150 | ** Approve an object held for moderation. |
| 151 | 151 | */ |
| 152 | -void moderation_approve(int rid){ | |
| 152 | +void moderation_approve(char class, int rid){ | |
| 153 | 153 | if( !moderation_pending(rid) ) return; |
| 154 | 154 | db_begin_transaction(); |
| 155 | 155 | db_multi_exec( |
| 156 | 156 | "DELETE FROM private WHERE rid=%d;" |
| 157 | 157 | "INSERT OR IGNORE INTO unclustered VALUES(%d);" |
| 158 | 158 | "INSERT OR IGNORE INTO unsent VALUES(%d);", |
| 159 | 159 | rid, rid, rid |
| 160 | 160 | ); |
| 161 | 161 | db_multi_exec("DELETE FROM modreq WHERE objid=%d", rid); |
| 162 | - admin_log("Approved moderation of rid %d.", rid); | |
| 162 | + admin_log("Approved moderation of rid %c-%d.", class, rid); | |
| 163 | + if( class!='a' ) search_doc_touch(class, rid, 0); | |
| 163 | 164 | db_end_transaction(0); |
| 164 | 165 | } |
| 165 | 166 | |
| 166 | 167 | /* |
| 167 | 168 | ** WEBPAGE: modreq |
| 168 | 169 |
| --- src/moderate.c | |
| +++ src/moderate.c | |
| @@ -147,21 +147,22 @@ | |
| 147 | } |
| 148 | |
| 149 | /* |
| 150 | ** Approve an object held for moderation. |
| 151 | */ |
| 152 | void moderation_approve(int rid){ |
| 153 | if( !moderation_pending(rid) ) return; |
| 154 | db_begin_transaction(); |
| 155 | db_multi_exec( |
| 156 | "DELETE FROM private WHERE rid=%d;" |
| 157 | "INSERT OR IGNORE INTO unclustered VALUES(%d);" |
| 158 | "INSERT OR IGNORE INTO unsent VALUES(%d);", |
| 159 | rid, rid, rid |
| 160 | ); |
| 161 | db_multi_exec("DELETE FROM modreq WHERE objid=%d", rid); |
| 162 | admin_log("Approved moderation of rid %d.", rid); |
| 163 | db_end_transaction(0); |
| 164 | } |
| 165 | |
| 166 | /* |
| 167 | ** WEBPAGE: modreq |
| 168 |
| --- src/moderate.c | |
| +++ src/moderate.c | |
| @@ -147,21 +147,22 @@ | |
| 147 | } |
| 148 | |
| 149 | /* |
| 150 | ** Approve an object held for moderation. |
| 151 | */ |
| 152 | void moderation_approve(char class, int rid){ |
| 153 | if( !moderation_pending(rid) ) return; |
| 154 | db_begin_transaction(); |
| 155 | db_multi_exec( |
| 156 | "DELETE FROM private WHERE rid=%d;" |
| 157 | "INSERT OR IGNORE INTO unclustered VALUES(%d);" |
| 158 | "INSERT OR IGNORE INTO unsent VALUES(%d);", |
| 159 | rid, rid, rid |
| 160 | ); |
| 161 | db_multi_exec("DELETE FROM modreq WHERE objid=%d", rid); |
| 162 | admin_log("Approved moderation of rid %c-%d.", class, rid); |
| 163 | if( class!='a' ) search_doc_touch(class, rid, 0); |
| 164 | db_end_transaction(0); |
| 165 | } |
| 166 | |
| 167 | /* |
| 168 | ** WEBPAGE: modreq |
| 169 |
+1
-1
| --- src/search.c | ||
| +++ src/search.c | ||
| @@ -1585,11 +1585,11 @@ | ||
| 1585 | 1585 | ** updated. If the document has already been indexed, then unindex it |
| 1586 | 1586 | ** now while we still have access to the old content. Add the document |
| 1587 | 1587 | ** to the queue of documents that need to be indexed or reindexed. |
| 1588 | 1588 | */ |
| 1589 | 1589 | void search_doc_touch(char cType, int rid, const char *zName){ |
| 1590 | - if( search_index_exists() ){ | |
| 1590 | + if( search_index_exists() && !content_is_private(rid) ){ | |
| 1591 | 1591 | char zType[2]; |
| 1592 | 1592 | zType[0] = cType; |
| 1593 | 1593 | zType[1] = 0; |
| 1594 | 1594 | search_sql_setup(g.db); |
| 1595 | 1595 | db_multi_exec( |
| 1596 | 1596 |
| --- src/search.c | |
| +++ src/search.c | |
| @@ -1585,11 +1585,11 @@ | |
| 1585 | ** updated. If the document has already been indexed, then unindex it |
| 1586 | ** now while we still have access to the old content. Add the document |
| 1587 | ** to the queue of documents that need to be indexed or reindexed. |
| 1588 | */ |
| 1589 | void search_doc_touch(char cType, int rid, const char *zName){ |
| 1590 | if( search_index_exists() ){ |
| 1591 | char zType[2]; |
| 1592 | zType[0] = cType; |
| 1593 | zType[1] = 0; |
| 1594 | search_sql_setup(g.db); |
| 1595 | db_multi_exec( |
| 1596 |
| --- src/search.c | |
| +++ src/search.c | |
| @@ -1585,11 +1585,11 @@ | |
| 1585 | ** updated. If the document has already been indexed, then unindex it |
| 1586 | ** now while we still have access to the old content. Add the document |
| 1587 | ** to the queue of documents that need to be indexed or reindexed. |
| 1588 | */ |
| 1589 | void search_doc_touch(char cType, int rid, const char *zName){ |
| 1590 | if( search_index_exists() && !content_is_private(rid) ){ |
| 1591 | char zType[2]; |
| 1592 | zType[0] = cType; |
| 1593 | zType[1] = 0; |
| 1594 | search_sql_setup(g.db); |
| 1595 | db_multi_exec( |
| 1596 |