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]

drh 2020-04-18 19:40 trunk
Commit bed0dd1a956c08874c6defeb99dcafd3e5eb5246f830d86b9014860914f8e235
1 file changed +7
--- src/forum.c
+++ src/forum.c
@@ -156,10 +156,11 @@
156156
static ForumThread *forumthread_create(int froot, int computeHierarchy){
157157
ForumThread *pThread;
158158
ForumEntry *pEntry;
159159
Stmt q;
160160
int sid = 1;
161
+ Bag seen = Bag_INIT;
161162
pThread = fossil_malloc( sizeof(*pThread) );
162163
memset(pThread, 0, sizeof(*pThread));
163164
db_prepare(&q,
164165
"SELECT fpid, firt, fprev, (SELECT uuid FROM blob WHERE rid=fpid)"
165166
" FROM forumpost"
@@ -175,18 +176,24 @@
175176
pEntry->zUuid = fossil_strdup(db_column_text(&q,3));
176177
pEntry->mfirt = pEntry->firt;
177178
pEntry->sid = sid++;
178179
pEntry->pPrev = pThread->pLast;
179180
pEntry->pNext = 0;
181
+ bag_insert(&seen, pEntry->fpid);
180182
if( pThread->pLast==0 ){
181183
pThread->pFirst = pEntry;
182184
}else{
183185
pThread->pLast->pNext = pEntry;
184186
}
187
+ if( pEntry->firt && !bag_find(&seen,pEntry->firt) ){
188
+ pEntry->firt = froot;
189
+ pEntry->mfirt = froot;
190
+ }
185191
pThread->pLast = pEntry;
186192
}
187193
db_finalize(&q);
194
+ bag_clear(&seen);
188195
189196
/* Establish which entries are the latest edit. After this loop
190197
** completes, entries that have non-NULL pLeaf should not be
191198
** displayed.
192199
*/
193200
--- 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

Keyboard Shortcuts

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