Fossil SCM

Further improvements to webpage_error() and webpage_assert(). Fix forum processing so that moderator approval and disapproval work. Add the "Delete" feature to forum that simply nulls out the page using an edit.

drh 2018-07-25 17:53 forum-v2
Commit 32bbb9a9fc6ee546042859c663465093899048862bff23a4f9dcf8b23578ba74
+48 -26
--- src/forum.c
+++ src/forum.c
@@ -126,39 +126,34 @@
126126
login_check_credentials();
127127
if( !g.perm.RdForum ){
128128
login_needed(g.anon.RdForum);
129129
return;
130130
}
131
- style_header("Forum");
132131
if( zName==0 ){
133
- @ <p class='generalError'>Missing name= query parameter</p>
134
- style_footer();
135
- return;
132
+ webpage_error("Missing \"name=\" query parameter");
136133
}
137134
fpid = symbolic_name_to_rid(zName, "f");
138135
if( fpid<=0 ){
139
- @ <p class='generalError'>Unknown or ambiguous forum id in the "name="
140
- @ query parameter</p>
141
- style_footer();
142
- return;
136
+ webpage_error("Unknown or ambiguous forum id: \"%s\"", zName);
143137
}
138
+ style_header("Forum");
144139
froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid);
145140
if( froot==0 ){
146
- @ <p class='generalError'>Invalid forum id in the "name="
147
- @ query parameter</p>
148
- style_footer();
149
- return;
141
+ webpage_error("Not a forum post: \"%s\"", zName);
150142
}
151143
forum_thread_chronological(froot);
152144
style_footer();
153145
}
154146
155147
/*
156148
** Return true if a forum post should be moderated.
157149
*/
158150
static int forum_need_moderation(void){
159
- return !g.perm.WrTForum && !g.perm.ModForum && P("domod")==0;
151
+ if( P("domod") ) return 1;
152
+ if( g.perm.WrTForum ) return 0;
153
+ if( g.perm.ModForum ) return 0;
154
+ return 1;
160155
}
161156
162157
/*
163158
** Add a new Forum Post artifact to the repository.
164159
**
@@ -235,13 +230,11 @@
235230
blob_copy(&formatCheck, &x);
236231
pPost = manifest_parse(&formatCheck, 0, &errMsg);
237232
if( pPost==0 ){
238233
webpage_error("malformed forum post artifact - %s", blob_str(&errMsg));
239234
}
240
- if( pPost->type!=CFTYPE_FORUM ){
241
- webpage_error("forum post artifact malformed");
242
- }
235
+ webpage_assert( pPost->type==CFTYPE_FORUM );
243236
manifest_destroy(pPost);
244237
245238
if( P("dryrun") ){
246239
@ <div class='debug'>
247240
@ This is the artifact that would have been generated:
@@ -330,10 +323,12 @@
330323
int fpid;
331324
Manifest *pPost;
332325
const char *zMimetype = 0;
333326
const char *zContent = 0;
334327
const char *zTitle = 0;
328
+ int isCsrfSafe;
329
+ int isDelete = 0;
335330
336331
login_check_credentials();
337332
if( !g.perm.WrForum ){
338333
login_needed(g.anon.WrForum);
339334
return;
@@ -340,57 +335,81 @@
340335
}
341336
fpid = symbolic_name_to_rid(PD("fpid",""), "f");
342337
if( fpid<=0 || (pPost = manifest_get(fpid, CFTYPE_FORUM, 0))==0 ){
343338
webpage_error("Missing or invalid fpid query parameter");
344339
}
345
- if( g.perm.ModForum ){
340
+ if( P("cancel") ){
341
+ cgi_redirectf("%R/forumthread/%S",P("fpid"));
342
+ return;
343
+ }
344
+ isCsrfSafe = cgi_csrf_safe(1);
345
+ if( g.perm.ModForum && isCsrfSafe ){
346346
if( P("approve") ){
347
- webpage_not_yet_implemented();
347
+ moderation_approve(fpid);
348
+ cgi_redirectf("%R/forumthread/%S",P("fpid"));
348349
return;
349350
}
350351
if( P("reject") ){
351
- webpage_not_yet_implemented();
352
+ moderation_disapprove(fpid);
353
+ cgi_redirectf("%R/forumthread/%S",P("fpid"));
352354
return;
353355
}
354356
}
355
- if( P("submit") && cgi_csrf_safe(1) ){
357
+ isDelete = P("nullout")!=0;
358
+ if( P("submit") && isCsrfSafe ){
356359
int done = 1;
357360
const char *zMimetype = PD("mimetype","text/x-fossil-wiki");
358361
const char *zContent = PDT("content","");
359362
if( P("reply") ){
360363
done = forum_post(0, fpid, 0, 0, zMimetype, zContent);
361
- }else if( P("edit") ){
364
+ }else if( P("edit") || isDelete ){
362365
done = forum_post(P("title"), 0, fpid, 0, zMimetype, zContent);
363366
}else{
364367
webpage_error("Missing 'reply' query parameter");
365368
}
366369
if( done ) return;
367370
}
368
- if( P("edit") ){
371
+ if( isDelete ){
372
+ zMimetype = "text/x-fossil-wiki";
373
+ zContent = "<i>Deleted</i>";
374
+ if( pPost->zThreadTitle ) zTitle = "<i>Deleted</i>";
375
+ @ <h1>Original Post:</h1>
376
+ forum_render(pPost->zThreadTitle, pPost->zMimetype, pPost->zWiki);
377
+ @ <h1>Change Into:</h1>
378
+ forum_render(zTitle, zMimetype, zContent);
379
+ @ <form action="%R/forumedit" method="POST">
380
+ @ <input type="hidden" name="fpid" value="%h(P("fpid"))">
381
+ @ <input type="hidden" name="nullout" value="1">
382
+ @ <input type="hidden" name="mimetype" value="%h(zMimetype)">
383
+ @ <input type="hidden" name="content" value="%h(zContent)">
384
+ if( zTitle ){
385
+ @ <input type="hidden" name="title" value="%h(zTitle)">
386
+ }
387
+ }else if( P("edit") ){
369388
/* Provide an edit to the fpid post */
370389
zMimetype = P("mimetype");
371390
zContent = PT("content");
372391
zTitle = P("title");
373392
if( zContent==0 ) zContent = fossil_strdup(pPost->zWiki);
374393
if( zMimetype==0 ) zMimetype = fossil_strdup(pPost->zMimetype);
375394
if( zTitle==0 && pPost->zThreadTitle!=0 ){
376395
zTitle = fossil_strdup(pPost->zThreadTitle);
377396
}
378
- style_header("Forum Edit");
397
+ style_header("Edit Forum Post");
379398
@ <h1>Original Post:</h1>
380399
forum_render(pPost->zThreadTitle, pPost->zMimetype, pPost->zWiki);
381400
if( P("preview") ){
382401
@ <h1>Preview Of Editted Post:</h1>
383402
forum_render(zTitle, zMimetype, zContent);
384403
}
385
- @ <h1>
386404
@ <h1>Enter A Reply:</h1>
387405
@ <form action="%R/forumedit" method="POST">
388406
@ <input type="hidden" name="fpid" value="%h(P("fpid"))">
389407
@ <input type="hidden" name="edit" value="1">
390408
forum_entry_widget(zTitle, zMimetype, zContent);
391409
}else{
410
+ /* Reply */
392411
zMimetype = PD("mimetype","text/x-fossil-wiki");
393412
zContent = PDT("content","");
394413
style_header("Forum Reply");
395414
@ <h1>Replying To:</h1>
396415
forum_render(0, pPost->zMimetype, pPost->zWiki);
@@ -402,12 +421,15 @@
402421
@ <form action="%R/forumedit" method="POST">
403422
@ <input type="hidden" name="fpid" value="%h(P("fpid"))">
404423
@ <input type="hidden" name="reply" value="1">
405424
forum_entry_widget(0, zMimetype, zContent);
406425
}
407
- @ <input type="submit" name="preview" value="Preview">
408
- if( P("preview") ){
426
+ if( !isDelete ){
427
+ @ <input type="submit" name="preview" value="Preview">
428
+ }
429
+ @ <input type="submit" name="cancel" value="Cancel">
430
+ if( P("preview") || isDelete ){
409431
@ <input type="submit" name="submit" value="Submit">
410432
}
411433
if( g.perm.Debug ){
412434
/* For the test-forumnew page add these extra debugging controls */
413435
@ <div class="debug">
414436
--- src/forum.c
+++ src/forum.c
@@ -126,39 +126,34 @@
126 login_check_credentials();
127 if( !g.perm.RdForum ){
128 login_needed(g.anon.RdForum);
129 return;
130 }
131 style_header("Forum");
132 if( zName==0 ){
133 @ <p class='generalError'>Missing name= query parameter</p>
134 style_footer();
135 return;
136 }
137 fpid = symbolic_name_to_rid(zName, "f");
138 if( fpid<=0 ){
139 @ <p class='generalError'>Unknown or ambiguous forum id in the "name="
140 @ query parameter</p>
141 style_footer();
142 return;
143 }
 
144 froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid);
145 if( froot==0 ){
146 @ <p class='generalError'>Invalid forum id in the "name="
147 @ query parameter</p>
148 style_footer();
149 return;
150 }
151 forum_thread_chronological(froot);
152 style_footer();
153 }
154
155 /*
156 ** Return true if a forum post should be moderated.
157 */
158 static int forum_need_moderation(void){
159 return !g.perm.WrTForum && !g.perm.ModForum && P("domod")==0;
 
 
 
160 }
161
162 /*
163 ** Add a new Forum Post artifact to the repository.
164 **
@@ -235,13 +230,11 @@
235 blob_copy(&formatCheck, &x);
236 pPost = manifest_parse(&formatCheck, 0, &errMsg);
237 if( pPost==0 ){
238 webpage_error("malformed forum post artifact - %s", blob_str(&errMsg));
239 }
240 if( pPost->type!=CFTYPE_FORUM ){
241 webpage_error("forum post artifact malformed");
242 }
243 manifest_destroy(pPost);
244
245 if( P("dryrun") ){
246 @ <div class='debug'>
247 @ This is the artifact that would have been generated:
@@ -330,10 +323,12 @@
330 int fpid;
331 Manifest *pPost;
332 const char *zMimetype = 0;
333 const char *zContent = 0;
334 const char *zTitle = 0;
 
 
335
336 login_check_credentials();
337 if( !g.perm.WrForum ){
338 login_needed(g.anon.WrForum);
339 return;
@@ -340,57 +335,81 @@
340 }
341 fpid = symbolic_name_to_rid(PD("fpid",""), "f");
342 if( fpid<=0 || (pPost = manifest_get(fpid, CFTYPE_FORUM, 0))==0 ){
343 webpage_error("Missing or invalid fpid query parameter");
344 }
345 if( g.perm.ModForum ){
 
 
 
 
 
346 if( P("approve") ){
347 webpage_not_yet_implemented();
 
348 return;
349 }
350 if( P("reject") ){
351 webpage_not_yet_implemented();
 
352 return;
353 }
354 }
355 if( P("submit") && cgi_csrf_safe(1) ){
 
356 int done = 1;
357 const char *zMimetype = PD("mimetype","text/x-fossil-wiki");
358 const char *zContent = PDT("content","");
359 if( P("reply") ){
360 done = forum_post(0, fpid, 0, 0, zMimetype, zContent);
361 }else if( P("edit") ){
362 done = forum_post(P("title"), 0, fpid, 0, zMimetype, zContent);
363 }else{
364 webpage_error("Missing 'reply' query parameter");
365 }
366 if( done ) return;
367 }
368 if( P("edit") ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
369 /* Provide an edit to the fpid post */
370 zMimetype = P("mimetype");
371 zContent = PT("content");
372 zTitle = P("title");
373 if( zContent==0 ) zContent = fossil_strdup(pPost->zWiki);
374 if( zMimetype==0 ) zMimetype = fossil_strdup(pPost->zMimetype);
375 if( zTitle==0 && pPost->zThreadTitle!=0 ){
376 zTitle = fossil_strdup(pPost->zThreadTitle);
377 }
378 style_header("Forum Edit");
379 @ <h1>Original Post:</h1>
380 forum_render(pPost->zThreadTitle, pPost->zMimetype, pPost->zWiki);
381 if( P("preview") ){
382 @ <h1>Preview Of Editted Post:</h1>
383 forum_render(zTitle, zMimetype, zContent);
384 }
385 @ <h1>
386 @ <h1>Enter A Reply:</h1>
387 @ <form action="%R/forumedit" method="POST">
388 @ <input type="hidden" name="fpid" value="%h(P("fpid"))">
389 @ <input type="hidden" name="edit" value="1">
390 forum_entry_widget(zTitle, zMimetype, zContent);
391 }else{
 
392 zMimetype = PD("mimetype","text/x-fossil-wiki");
393 zContent = PDT("content","");
394 style_header("Forum Reply");
395 @ <h1>Replying To:</h1>
396 forum_render(0, pPost->zMimetype, pPost->zWiki);
@@ -402,12 +421,15 @@
402 @ <form action="%R/forumedit" method="POST">
403 @ <input type="hidden" name="fpid" value="%h(P("fpid"))">
404 @ <input type="hidden" name="reply" value="1">
405 forum_entry_widget(0, zMimetype, zContent);
406 }
407 @ <input type="submit" name="preview" value="Preview">
408 if( P("preview") ){
 
 
 
409 @ <input type="submit" name="submit" value="Submit">
410 }
411 if( g.perm.Debug ){
412 /* For the test-forumnew page add these extra debugging controls */
413 @ <div class="debug">
414
--- src/forum.c
+++ src/forum.c
@@ -126,39 +126,34 @@
126 login_check_credentials();
127 if( !g.perm.RdForum ){
128 login_needed(g.anon.RdForum);
129 return;
130 }
 
131 if( zName==0 ){
132 webpage_error("Missing \"name=\" query parameter");
 
 
133 }
134 fpid = symbolic_name_to_rid(zName, "f");
135 if( fpid<=0 ){
136 webpage_error("Unknown or ambiguous forum id: \"%s\"", zName);
 
 
 
137 }
138 style_header("Forum");
139 froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid);
140 if( froot==0 ){
141 webpage_error("Not a forum post: \"%s\"", zName);
 
 
 
142 }
143 forum_thread_chronological(froot);
144 style_footer();
145 }
146
147 /*
148 ** Return true if a forum post should be moderated.
149 */
150 static int forum_need_moderation(void){
151 if( P("domod") ) return 1;
152 if( g.perm.WrTForum ) return 0;
153 if( g.perm.ModForum ) return 0;
154 return 1;
155 }
156
157 /*
158 ** Add a new Forum Post artifact to the repository.
159 **
@@ -235,13 +230,11 @@
230 blob_copy(&formatCheck, &x);
231 pPost = manifest_parse(&formatCheck, 0, &errMsg);
232 if( pPost==0 ){
233 webpage_error("malformed forum post artifact - %s", blob_str(&errMsg));
234 }
235 webpage_assert( pPost->type==CFTYPE_FORUM );
 
 
236 manifest_destroy(pPost);
237
238 if( P("dryrun") ){
239 @ <div class='debug'>
240 @ This is the artifact that would have been generated:
@@ -330,10 +323,12 @@
323 int fpid;
324 Manifest *pPost;
325 const char *zMimetype = 0;
326 const char *zContent = 0;
327 const char *zTitle = 0;
328 int isCsrfSafe;
329 int isDelete = 0;
330
331 login_check_credentials();
332 if( !g.perm.WrForum ){
333 login_needed(g.anon.WrForum);
334 return;
@@ -340,57 +335,81 @@
335 }
336 fpid = symbolic_name_to_rid(PD("fpid",""), "f");
337 if( fpid<=0 || (pPost = manifest_get(fpid, CFTYPE_FORUM, 0))==0 ){
338 webpage_error("Missing or invalid fpid query parameter");
339 }
340 if( P("cancel") ){
341 cgi_redirectf("%R/forumthread/%S",P("fpid"));
342 return;
343 }
344 isCsrfSafe = cgi_csrf_safe(1);
345 if( g.perm.ModForum && isCsrfSafe ){
346 if( P("approve") ){
347 moderation_approve(fpid);
348 cgi_redirectf("%R/forumthread/%S",P("fpid"));
349 return;
350 }
351 if( P("reject") ){
352 moderation_disapprove(fpid);
353 cgi_redirectf("%R/forumthread/%S",P("fpid"));
354 return;
355 }
356 }
357 isDelete = P("nullout")!=0;
358 if( P("submit") && isCsrfSafe ){
359 int done = 1;
360 const char *zMimetype = PD("mimetype","text/x-fossil-wiki");
361 const char *zContent = PDT("content","");
362 if( P("reply") ){
363 done = forum_post(0, fpid, 0, 0, zMimetype, zContent);
364 }else if( P("edit") || isDelete ){
365 done = forum_post(P("title"), 0, fpid, 0, zMimetype, zContent);
366 }else{
367 webpage_error("Missing 'reply' query parameter");
368 }
369 if( done ) return;
370 }
371 if( isDelete ){
372 zMimetype = "text/x-fossil-wiki";
373 zContent = "<i>Deleted</i>";
374 if( pPost->zThreadTitle ) zTitle = "<i>Deleted</i>";
375 @ <h1>Original Post:</h1>
376 forum_render(pPost->zThreadTitle, pPost->zMimetype, pPost->zWiki);
377 @ <h1>Change Into:</h1>
378 forum_render(zTitle, zMimetype, zContent);
379 @ <form action="%R/forumedit" method="POST">
380 @ <input type="hidden" name="fpid" value="%h(P("fpid"))">
381 @ <input type="hidden" name="nullout" value="1">
382 @ <input type="hidden" name="mimetype" value="%h(zMimetype)">
383 @ <input type="hidden" name="content" value="%h(zContent)">
384 if( zTitle ){
385 @ <input type="hidden" name="title" value="%h(zTitle)">
386 }
387 }else if( P("edit") ){
388 /* Provide an edit to the fpid post */
389 zMimetype = P("mimetype");
390 zContent = PT("content");
391 zTitle = P("title");
392 if( zContent==0 ) zContent = fossil_strdup(pPost->zWiki);
393 if( zMimetype==0 ) zMimetype = fossil_strdup(pPost->zMimetype);
394 if( zTitle==0 && pPost->zThreadTitle!=0 ){
395 zTitle = fossil_strdup(pPost->zThreadTitle);
396 }
397 style_header("Edit Forum Post");
398 @ <h1>Original Post:</h1>
399 forum_render(pPost->zThreadTitle, pPost->zMimetype, pPost->zWiki);
400 if( P("preview") ){
401 @ <h1>Preview Of Editted Post:</h1>
402 forum_render(zTitle, zMimetype, zContent);
403 }
 
404 @ <h1>Enter A Reply:</h1>
405 @ <form action="%R/forumedit" method="POST">
406 @ <input type="hidden" name="fpid" value="%h(P("fpid"))">
407 @ <input type="hidden" name="edit" value="1">
408 forum_entry_widget(zTitle, zMimetype, zContent);
409 }else{
410 /* Reply */
411 zMimetype = PD("mimetype","text/x-fossil-wiki");
412 zContent = PDT("content","");
413 style_header("Forum Reply");
414 @ <h1>Replying To:</h1>
415 forum_render(0, pPost->zMimetype, pPost->zWiki);
@@ -402,12 +421,15 @@
421 @ <form action="%R/forumedit" method="POST">
422 @ <input type="hidden" name="fpid" value="%h(P("fpid"))">
423 @ <input type="hidden" name="reply" value="1">
424 forum_entry_widget(0, zMimetype, zContent);
425 }
426 if( !isDelete ){
427 @ <input type="submit" name="preview" value="Preview">
428 }
429 @ <input type="submit" name="cancel" value="Cancel">
430 if( P("preview") || isDelete ){
431 @ <input type="submit" name="submit" value="Submit">
432 }
433 if( g.perm.Debug ){
434 /* For the test-forumnew page add these extra debugging controls */
435 @ <div class="debug">
436
+12 -1
--- src/main.c
+++ src/main.c
@@ -2806,10 +2806,12 @@
28062806
** case=1 Issue a fossil_warning() while generating the page.
28072807
** case=2 Extra db_begin_transaction()
28082808
** case=3 Extra db_end_transaction()
28092809
** case=4 Error during SQL processing
28102810
** case=5 Call the segfault handler
2811
+** case=6 Call webpage_assert()
2812
+** case=7 Call webpage_error()
28112813
*/
28122814
void test_warning_page(void){
28132815
int iCase = atoi(PD("case","0"));
28142816
int i;
28152817
login_check_credentials();
@@ -2823,11 +2825,11 @@
28232825
@ <p>Generate a message to the <a href="%R/errorlog">error log</a>
28242826
@ by clicking on one of the following cases:
28252827
}else{
28262828
@ <p>This is the test page for case=%d(iCase). All possible cases:
28272829
}
2828
- for(i=1; i<=5; i++){
2830
+ for(i=1; i<=7; i++){
28292831
@ <a href='./test-warning?case=%d(i)'>[%d(i)]</a>
28302832
}
28312833
@ </p>
28322834
@ <p><ol>
28332835
@ <li value='1'> Call fossil_warning()
@@ -2852,9 +2854,18 @@
28522854
}
28532855
@ <li value='5'> simulate segfault handling
28542856
if( iCase==5 ){
28552857
sigsegv_handler(0);
28562858
}
2859
+ @ <li value='6'> call webpage_assert(0)
2860
+ if( iCase==6 ){
2861
+ webpage_assert( 5==7 );
2862
+ }
2863
+ @ <li value='7'> call webpage_error()"
2864
+ if( iCase==7 ){
2865
+ cgi_reset_content();
2866
+ webpage_error("Case 7 from /test-warning");
2867
+ }
28572868
@ </ol>
28582869
@ <p>End of test</p>
28592870
style_footer();
28602871
}
28612872
--- src/main.c
+++ src/main.c
@@ -2806,10 +2806,12 @@
2806 ** case=1 Issue a fossil_warning() while generating the page.
2807 ** case=2 Extra db_begin_transaction()
2808 ** case=3 Extra db_end_transaction()
2809 ** case=4 Error during SQL processing
2810 ** case=5 Call the segfault handler
 
 
2811 */
2812 void test_warning_page(void){
2813 int iCase = atoi(PD("case","0"));
2814 int i;
2815 login_check_credentials();
@@ -2823,11 +2825,11 @@
2823 @ <p>Generate a message to the <a href="%R/errorlog">error log</a>
2824 @ by clicking on one of the following cases:
2825 }else{
2826 @ <p>This is the test page for case=%d(iCase). All possible cases:
2827 }
2828 for(i=1; i<=5; i++){
2829 @ <a href='./test-warning?case=%d(i)'>[%d(i)]</a>
2830 }
2831 @ </p>
2832 @ <p><ol>
2833 @ <li value='1'> Call fossil_warning()
@@ -2852,9 +2854,18 @@
2852 }
2853 @ <li value='5'> simulate segfault handling
2854 if( iCase==5 ){
2855 sigsegv_handler(0);
2856 }
 
 
 
 
 
 
 
 
 
2857 @ </ol>
2858 @ <p>End of test</p>
2859 style_footer();
2860 }
2861
--- src/main.c
+++ src/main.c
@@ -2806,10 +2806,12 @@
2806 ** case=1 Issue a fossil_warning() while generating the page.
2807 ** case=2 Extra db_begin_transaction()
2808 ** case=3 Extra db_end_transaction()
2809 ** case=4 Error during SQL processing
2810 ** case=5 Call the segfault handler
2811 ** case=6 Call webpage_assert()
2812 ** case=7 Call webpage_error()
2813 */
2814 void test_warning_page(void){
2815 int iCase = atoi(PD("case","0"));
2816 int i;
2817 login_check_credentials();
@@ -2823,11 +2825,11 @@
2825 @ <p>Generate a message to the <a href="%R/errorlog">error log</a>
2826 @ by clicking on one of the following cases:
2827 }else{
2828 @ <p>This is the test page for case=%d(iCase). All possible cases:
2829 }
2830 for(i=1; i<=7; i++){
2831 @ <a href='./test-warning?case=%d(i)'>[%d(i)]</a>
2832 }
2833 @ </p>
2834 @ <p><ol>
2835 @ <li value='1'> Call fossil_warning()
@@ -2852,9 +2854,18 @@
2854 }
2855 @ <li value='5'> simulate segfault handling
2856 if( iCase==5 ){
2857 sigsegv_handler(0);
2858 }
2859 @ <li value='6'> call webpage_assert(0)
2860 if( iCase==6 ){
2861 webpage_assert( 5==7 );
2862 }
2863 @ <li value='7'> call webpage_error()"
2864 if( iCase==7 ){
2865 cgi_reset_content();
2866 webpage_error("Case 7 from /test-warning");
2867 }
2868 @ </ol>
2869 @ <p>End of test</p>
2870 style_footer();
2871 }
2872
--- src/moderate.c
+++ src/moderate.c
@@ -101,10 +101,13 @@
101101
"DELETE FROM tagxref WHERE rid=%d;"
102102
"DELETE FROM private WHERE rid=%d;"
103103
"DELETE FROM attachment WHERE attachid=%d;",
104104
rid, rid, rid, rid, rid, rid
105105
);
106
+ if( db_table_exists("repository","forumpost") ){
107
+ db_multi_exec("DELETE FROM forumpost WHERE fpid=%d", rid);
108
+ }
106109
zTktid = db_text(0, "SELECT tktid FROM modreq WHERE objid=%d", rid);
107110
if( zTktid && zTktid[0] ){
108111
ticket_rebuild_entry(zTktid);
109112
fossil_free(zTktid);
110113
}
111114
--- src/moderate.c
+++ src/moderate.c
@@ -101,10 +101,13 @@
101 "DELETE FROM tagxref WHERE rid=%d;"
102 "DELETE FROM private WHERE rid=%d;"
103 "DELETE FROM attachment WHERE attachid=%d;",
104 rid, rid, rid, rid, rid, rid
105 );
 
 
 
106 zTktid = db_text(0, "SELECT tktid FROM modreq WHERE objid=%d", rid);
107 if( zTktid && zTktid[0] ){
108 ticket_rebuild_entry(zTktid);
109 fossil_free(zTktid);
110 }
111
--- src/moderate.c
+++ src/moderate.c
@@ -101,10 +101,13 @@
101 "DELETE FROM tagxref WHERE rid=%d;"
102 "DELETE FROM private WHERE rid=%d;"
103 "DELETE FROM attachment WHERE attachid=%d;",
104 rid, rid, rid, rid, rid, rid
105 );
106 if( db_table_exists("repository","forumpost") ){
107 db_multi_exec("DELETE FROM forumpost WHERE fpid=%d", rid);
108 }
109 zTktid = db_text(0, "SELECT tktid FROM modreq WHERE objid=%d", rid);
110 if( zTktid && zTktid[0] ){
111 ticket_rebuild_entry(zTktid);
112 fossil_free(zTktid);
113 }
114
+13 -3
--- src/style.c
+++ src/style.c
@@ -970,10 +970,11 @@
970970
zErr = vmprintf(zFormat, ap);
971971
va_end(ap);
972972
style_header("Bad Request");
973973
@ <h1>/%h(g.zPath): %h(zErr)</h1>
974974
showAll = 0;
975
+ cgi_set_status(500, "Bad Request");
975976
}else if( !isAuth ){
976977
login_needed(0);
977978
return;
978979
}else{
979980
style_header("Environment Test");
@@ -1016,20 +1017,29 @@
10161017
@ </pre>
10171018
}
10181019
}
10191020
style_footer();
10201021
if( zErr ){
1021
- fossil_panic("webpage_error: %s", zErr);
1022
+ cgi_reply();
1023
+ fossil_exit(1);
10221024
}
10231025
}
10241026
10251027
/*
10261028
** Generate a Not Yet Implemented error page.
10271029
*/
10281030
void webpage_not_yet_implemented(void){
10291031
webpage_error("Not yet implemented");
10301032
}
1033
+
1034
+/*
1035
+** Generate a webpage for a webpage_assert().
1036
+*/
1037
+void webpage_assert_page(const char *zFile, int iLine, const char *zExpr){
1038
+ fossil_warning("assertion fault at %s:%d - %s", zFile, iLine, zExpr);
1039
+ cgi_reset_content();
1040
+ webpage_error("assertion fault at %s:%d - %s", zFile, iLine, zExpr);
1041
+}
10311042
10321043
#if INTERFACE
1033
-# define webpage_assert(T) \
1034
- if(!(T)){webpage_error("assertion failed %s:%d: %s",__FILE__,__LINE__,#T);}
1044
+# define webpage_assert(T) if(!(T)){webpage_assert_page(__FILE__,__LINE__,#T);}
10351045
#endif
10361046
--- src/style.c
+++ src/style.c
@@ -970,10 +970,11 @@
970 zErr = vmprintf(zFormat, ap);
971 va_end(ap);
972 style_header("Bad Request");
973 @ <h1>/%h(g.zPath): %h(zErr)</h1>
974 showAll = 0;
 
975 }else if( !isAuth ){
976 login_needed(0);
977 return;
978 }else{
979 style_header("Environment Test");
@@ -1016,20 +1017,29 @@
1016 @ </pre>
1017 }
1018 }
1019 style_footer();
1020 if( zErr ){
1021 fossil_panic("webpage_error: %s", zErr);
 
1022 }
1023 }
1024
1025 /*
1026 ** Generate a Not Yet Implemented error page.
1027 */
1028 void webpage_not_yet_implemented(void){
1029 webpage_error("Not yet implemented");
1030 }
 
 
 
 
 
 
 
 
 
1031
1032 #if INTERFACE
1033 # define webpage_assert(T) \
1034 if(!(T)){webpage_error("assertion failed %s:%d: %s",__FILE__,__LINE__,#T);}
1035 #endif
1036
--- src/style.c
+++ src/style.c
@@ -970,10 +970,11 @@
970 zErr = vmprintf(zFormat, ap);
971 va_end(ap);
972 style_header("Bad Request");
973 @ <h1>/%h(g.zPath): %h(zErr)</h1>
974 showAll = 0;
975 cgi_set_status(500, "Bad Request");
976 }else if( !isAuth ){
977 login_needed(0);
978 return;
979 }else{
980 style_header("Environment Test");
@@ -1016,20 +1017,29 @@
1017 @ </pre>
1018 }
1019 }
1020 style_footer();
1021 if( zErr ){
1022 cgi_reply();
1023 fossil_exit(1);
1024 }
1025 }
1026
1027 /*
1028 ** Generate a Not Yet Implemented error page.
1029 */
1030 void webpage_not_yet_implemented(void){
1031 webpage_error("Not yet implemented");
1032 }
1033
1034 /*
1035 ** Generate a webpage for a webpage_assert().
1036 */
1037 void webpage_assert_page(const char *zFile, int iLine, const char *zExpr){
1038 fossil_warning("assertion fault at %s:%d - %s", zFile, iLine, zExpr);
1039 cgi_reset_content();
1040 webpage_error("assertion fault at %s:%d - %s", zFile, iLine, zExpr);
1041 }
1042
1043 #if INTERFACE
1044 # define webpage_assert(T) if(!(T)){webpage_assert_page(__FILE__,__LINE__,#T);}
 
1045 #endif
1046

Keyboard Shortcuts

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