Fossil SCM
In the forum thread constructor, if an post in a forum thread is a phantom, reassign the descendents of that post to be descendents of the root. This fixes the hierarchical view for the problem described at [https://www.fossil-scm.org/forum/forumpost/dc623b995f]
Commit
bed0dd1a956c08874c6defeb99dcafd3e5eb5246f830d86b9014860914f8e235
Parent
14795faaee2db16…
1 file changed
+7
+7
| --- src/forum.c | ||
| +++ src/forum.c | ||
| @@ -156,10 +156,11 @@ | ||
| 156 | 156 | static ForumThread *forumthread_create(int froot, int computeHierarchy){ |
| 157 | 157 | ForumThread *pThread; |
| 158 | 158 | ForumEntry *pEntry; |
| 159 | 159 | Stmt q; |
| 160 | 160 | int sid = 1; |
| 161 | + Bag seen = Bag_INIT; | |
| 161 | 162 | pThread = fossil_malloc( sizeof(*pThread) ); |
| 162 | 163 | memset(pThread, 0, sizeof(*pThread)); |
| 163 | 164 | db_prepare(&q, |
| 164 | 165 | "SELECT fpid, firt, fprev, (SELECT uuid FROM blob WHERE rid=fpid)" |
| 165 | 166 | " FROM forumpost" |
| @@ -175,18 +176,24 @@ | ||
| 175 | 176 | pEntry->zUuid = fossil_strdup(db_column_text(&q,3)); |
| 176 | 177 | pEntry->mfirt = pEntry->firt; |
| 177 | 178 | pEntry->sid = sid++; |
| 178 | 179 | pEntry->pPrev = pThread->pLast; |
| 179 | 180 | pEntry->pNext = 0; |
| 181 | + bag_insert(&seen, pEntry->fpid); | |
| 180 | 182 | if( pThread->pLast==0 ){ |
| 181 | 183 | pThread->pFirst = pEntry; |
| 182 | 184 | }else{ |
| 183 | 185 | pThread->pLast->pNext = pEntry; |
| 184 | 186 | } |
| 187 | + if( pEntry->firt && !bag_find(&seen,pEntry->firt) ){ | |
| 188 | + pEntry->firt = froot; | |
| 189 | + pEntry->mfirt = froot; | |
| 190 | + } | |
| 185 | 191 | pThread->pLast = pEntry; |
| 186 | 192 | } |
| 187 | 193 | db_finalize(&q); |
| 194 | + bag_clear(&seen); | |
| 188 | 195 | |
| 189 | 196 | /* Establish which entries are the latest edit. After this loop |
| 190 | 197 | ** completes, entries that have non-NULL pLeaf should not be |
| 191 | 198 | ** displayed. |
| 192 | 199 | */ |
| 193 | 200 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -156,10 +156,11 @@ | |
| 156 | static ForumThread *forumthread_create(int froot, int computeHierarchy){ |
| 157 | ForumThread *pThread; |
| 158 | ForumEntry *pEntry; |
| 159 | Stmt q; |
| 160 | int sid = 1; |
| 161 | pThread = fossil_malloc( sizeof(*pThread) ); |
| 162 | memset(pThread, 0, sizeof(*pThread)); |
| 163 | db_prepare(&q, |
| 164 | "SELECT fpid, firt, fprev, (SELECT uuid FROM blob WHERE rid=fpid)" |
| 165 | " FROM forumpost" |
| @@ -175,18 +176,24 @@ | |
| 175 | pEntry->zUuid = fossil_strdup(db_column_text(&q,3)); |
| 176 | pEntry->mfirt = pEntry->firt; |
| 177 | pEntry->sid = sid++; |
| 178 | pEntry->pPrev = pThread->pLast; |
| 179 | pEntry->pNext = 0; |
| 180 | if( pThread->pLast==0 ){ |
| 181 | pThread->pFirst = pEntry; |
| 182 | }else{ |
| 183 | pThread->pLast->pNext = pEntry; |
| 184 | } |
| 185 | pThread->pLast = pEntry; |
| 186 | } |
| 187 | db_finalize(&q); |
| 188 | |
| 189 | /* Establish which entries are the latest edit. After this loop |
| 190 | ** completes, entries that have non-NULL pLeaf should not be |
| 191 | ** displayed. |
| 192 | */ |
| 193 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -156,10 +156,11 @@ | |
| 156 | static ForumThread *forumthread_create(int froot, int computeHierarchy){ |
| 157 | ForumThread *pThread; |
| 158 | ForumEntry *pEntry; |
| 159 | Stmt q; |
| 160 | int sid = 1; |
| 161 | Bag seen = Bag_INIT; |
| 162 | pThread = fossil_malloc( sizeof(*pThread) ); |
| 163 | memset(pThread, 0, sizeof(*pThread)); |
| 164 | db_prepare(&q, |
| 165 | "SELECT fpid, firt, fprev, (SELECT uuid FROM blob WHERE rid=fpid)" |
| 166 | " FROM forumpost" |
| @@ -175,18 +176,24 @@ | |
| 176 | pEntry->zUuid = fossil_strdup(db_column_text(&q,3)); |
| 177 | pEntry->mfirt = pEntry->firt; |
| 178 | pEntry->sid = sid++; |
| 179 | pEntry->pPrev = pThread->pLast; |
| 180 | pEntry->pNext = 0; |
| 181 | bag_insert(&seen, pEntry->fpid); |
| 182 | if( pThread->pLast==0 ){ |
| 183 | pThread->pFirst = pEntry; |
| 184 | }else{ |
| 185 | pThread->pLast->pNext = pEntry; |
| 186 | } |
| 187 | if( pEntry->firt && !bag_find(&seen,pEntry->firt) ){ |
| 188 | pEntry->firt = froot; |
| 189 | pEntry->mfirt = froot; |
| 190 | } |
| 191 | pThread->pLast = pEntry; |
| 192 | } |
| 193 | db_finalize(&q); |
| 194 | bag_clear(&seen); |
| 195 | |
| 196 | /* Establish which entries are the latest edit. After this loop |
| 197 | ** completes, entries that have non-NULL pLeaf should not be |
| 198 | ** displayed. |
| 199 | */ |
| 200 |