Fossil SCM

Fix an incorrect argument bug in forumpost_tag() which caused it to re-apply tags even if doing so would reapply the same value. The the test-forumpost-tag command. Minor www/forum.wiki touchups.

stephan 2026-06-09 19:39 UTC forum-editor-2026
Commit ab52bc833121dcc1e7d58a5f7bb2d600307cf942b8fc02df11349198b27cce06
2 files changed +40 -6 +7 -6
+40 -6
--- src/forum.c
+++ src/forum.c
@@ -410,15 +410,13 @@
410410
** no tag is added. Similarly, it will only remove a tag from a post
411411
** which has its own tag, and will not remove an inherited one from a
412412
** parent post.
413413
**
414414
** If addTag is true and frid is already tagged, this is a
415
-** no-op. Likewise, if addTag is false and frid is not tagged
416
-** (not accounting for an inherited closed tag), this is a no-op.
417
-**
418
-** If bCheckIrt is true then the forum post IRT hierarchy is searched
419
-** for the tag, otherwise only the given RID is checked.
415
+** no-op. Likewise, if addTag is false and frid is not tagged (not
416
+** accounting for a tag inherited via an in-response-to post), this is
417
+** a no-op.
420418
**
421419
** Returns a positive value (a new tag.tagid value) if it actually
422420
** creates a new tag, else 0. On error it returns a negative alue
423421
** and g.zErrMsg "should" contain details.
424422
**
@@ -465,11 +463,11 @@
465463
zValue = 0;
466464
}
467465
if( addTag && iTagged ){
468466
char *zOld = 0;
469467
int cmp;
470
- rid_has_tag2(iTagged, zTagName, &zOld);
468
+ rid_has_tag2(frid, zTagName, &zOld);
471469
cmp = fossil_strcmp(zOld, zValue);
472470
fossil_free(zOld);
473471
if( 0==cmp ){
474472
/* Same value - leave it as is. */
475473
db_end_transaction(0);
@@ -498,10 +496,46 @@
498496
zUuid, addTag ? '*' : '-', zTagName);
499497
fossil_free(zUuid);
500498
db_end_transaction(0);
501499
return trid;
502500
}
501
+
502
+/*
503
+** COMMAND: test-forumpost-tag
504
+**
505
+** Usage: %fossil test-forumpost-tag ?-cancel? THREADID TAGNAME TAGVAL
506
+**
507
+** A tester for forumpost_tag(). It always rolls back changes.
508
+*/
509
+void test_forumpost_tag_command(void){
510
+ int fpid;
511
+ int rc;
512
+ const char *zPost;
513
+ const char *zTag;
514
+ const char *zVal;
515
+ const int bAdd = find_option("cancel","",0)==0;
516
+
517
+ db_find_and_open_repository(0,0);
518
+ verify_all_options();
519
+ if( g.argc<5 ){
520
+ usage("forum-post-id tag-name value");
521
+ }
522
+ zPost = g.argv[2];
523
+ zTag = g.argv[3];
524
+ zVal = g.argv[4];
525
+
526
+ db_begin_transaction();
527
+ fpid = forumpost_head_rid2(zPost);
528
+ if( fpid<=0 ){
529
+ fossil_fatal("Cannot resolve post ID %s", zPost);
530
+ }
531
+ fossil_print("%s => %d => %z\n", zTag, fpid,
532
+ rid_to_uuid(fpid));
533
+ rc = forumpost_tag(fpid, bAdd, zTag, zVal);
534
+ fossil_print("tag fpid=%d taxgxref.tagid=%d\n", fpid, rc);
535
+ db_end_transaction(1);
536
+}
503537
504538
/*
505539
** Returns true if the forum-close-policy setting is true, else false,
506540
** caching the result for subsequent calls.
507541
*/
508542
--- src/forum.c
+++ src/forum.c
@@ -410,15 +410,13 @@
410 ** no tag is added. Similarly, it will only remove a tag from a post
411 ** which has its own tag, and will not remove an inherited one from a
412 ** parent post.
413 **
414 ** If addTag is true and frid is already tagged, this is a
415 ** no-op. Likewise, if addTag is false and frid is not tagged
416 ** (not accounting for an inherited closed tag), this is a no-op.
417 **
418 ** If bCheckIrt is true then the forum post IRT hierarchy is searched
419 ** for the tag, otherwise only the given RID is checked.
420 **
421 ** Returns a positive value (a new tag.tagid value) if it actually
422 ** creates a new tag, else 0. On error it returns a negative alue
423 ** and g.zErrMsg "should" contain details.
424 **
@@ -465,11 +463,11 @@
465 zValue = 0;
466 }
467 if( addTag && iTagged ){
468 char *zOld = 0;
469 int cmp;
470 rid_has_tag2(iTagged, zTagName, &zOld);
471 cmp = fossil_strcmp(zOld, zValue);
472 fossil_free(zOld);
473 if( 0==cmp ){
474 /* Same value - leave it as is. */
475 db_end_transaction(0);
@@ -498,10 +496,46 @@
498 zUuid, addTag ? '*' : '-', zTagName);
499 fossil_free(zUuid);
500 db_end_transaction(0);
501 return trid;
502 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
503
504 /*
505 ** Returns true if the forum-close-policy setting is true, else false,
506 ** caching the result for subsequent calls.
507 */
508
--- src/forum.c
+++ src/forum.c
@@ -410,15 +410,13 @@
410 ** no tag is added. Similarly, it will only remove a tag from a post
411 ** which has its own tag, and will not remove an inherited one from a
412 ** parent post.
413 **
414 ** If addTag is true and frid is already tagged, this is a
415 ** no-op. Likewise, if addTag is false and frid is not tagged (not
416 ** accounting for a tag inherited via an in-response-to post), this is
417 ** a no-op.
 
 
418 **
419 ** Returns a positive value (a new tag.tagid value) if it actually
420 ** creates a new tag, else 0. On error it returns a negative alue
421 ** and g.zErrMsg "should" contain details.
422 **
@@ -465,11 +463,11 @@
463 zValue = 0;
464 }
465 if( addTag && iTagged ){
466 char *zOld = 0;
467 int cmp;
468 rid_has_tag2(frid, zTagName, &zOld);
469 cmp = fossil_strcmp(zOld, zValue);
470 fossil_free(zOld);
471 if( 0==cmp ){
472 /* Same value - leave it as is. */
473 db_end_transaction(0);
@@ -498,10 +496,46 @@
496 zUuid, addTag ? '*' : '-', zTagName);
497 fossil_free(zUuid);
498 db_end_transaction(0);
499 return trid;
500 }
501
502 /*
503 ** COMMAND: test-forumpost-tag
504 **
505 ** Usage: %fossil test-forumpost-tag ?-cancel? THREADID TAGNAME TAGVAL
506 **
507 ** A tester for forumpost_tag(). It always rolls back changes.
508 */
509 void test_forumpost_tag_command(void){
510 int fpid;
511 int rc;
512 const char *zPost;
513 const char *zTag;
514 const char *zVal;
515 const int bAdd = find_option("cancel","",0)==0;
516
517 db_find_and_open_repository(0,0);
518 verify_all_options();
519 if( g.argc<5 ){
520 usage("forum-post-id tag-name value");
521 }
522 zPost = g.argv[2];
523 zTag = g.argv[3];
524 zVal = g.argv[4];
525
526 db_begin_transaction();
527 fpid = forumpost_head_rid2(zPost);
528 if( fpid<=0 ){
529 fossil_fatal("Cannot resolve post ID %s", zPost);
530 }
531 fossil_print("%s => %d => %z\n", zTag, fpid,
532 rid_to_uuid(fpid));
533 rc = forumpost_tag(fpid, bAdd, zTag, zVal);
534 fossil_print("tag fpid=%d taxgxref.tagid=%d\n", fpid, rc);
535 db_end_transaction(1);
536 }
537
538 /*
539 ** Returns true if the forum-close-policy setting is true, else false,
540 ** caching the result for subsequent calls.
541 */
542
+7 -6
--- www/forum.wiki
+++ www/forum.wiki
@@ -474,22 +474,23 @@
474474
rendering a newer version.
475475
476476
Caveat: a "closed" status is not recommended because it's easy to confuse with
477477
the <a href='#close-post'>"closed" tag feature</a>, which behaves considerably
478478
differently and predates that "status" tag support by about three years. The
479
-"closed" semantics cannot be trivially consolidated with those of "status".
479
+"closed" semantics cannot be trivially consolidated with those of "status"
480
+but we reserve the right to do so at some point.
480481
481482
<h2 name="attachments">Attachments</h2>
482483
483
-As of version 2.29 users with the [./caps/index.md|'B' capability]
484
-may attach files to forum posts. Files may not be attached until a
485
-forum post is saved for the first time, after which an "Attach" button
486
-will appear in the post when it is selected. Attached files undergo
484
+As of version 2.29 users with the [./caps/index.md|'B' capability] may
485
+attach files to forum posts. Files may not be attached until a forum
486
+post is saved for the first time, after which an "Attach" button will
487
+appear in the post when it is selected. Attached files undergo
487488
moderation exactly like forum posts do. When a moderator accepts a
488489
pending-moderation posts, all files attached to it which are also
489490
pending approval are also approved. Similarly, when a moderator
490
-rejects a pending-moderation post, all files attached to it when are
491
+rejects a pending-moderation post, all files attached to it which are
491492
also pending approval are rejected.
492493
493494
Developer notes regarding the save-before-attach limitation:
494495
495496
* We cannot add the attachment form to the current post editor
496497
--- www/forum.wiki
+++ www/forum.wiki
@@ -474,22 +474,23 @@
474 rendering a newer version.
475
476 Caveat: a "closed" status is not recommended because it's easy to confuse with
477 the <a href='#close-post'>"closed" tag feature</a>, which behaves considerably
478 differently and predates that "status" tag support by about three years. The
479 "closed" semantics cannot be trivially consolidated with those of "status".
 
480
481 <h2 name="attachments">Attachments</h2>
482
483 As of version 2.29 users with the [./caps/index.md|'B' capability]
484 may attach files to forum posts. Files may not be attached until a
485 forum post is saved for the first time, after which an "Attach" button
486 will appear in the post when it is selected. Attached files undergo
487 moderation exactly like forum posts do. When a moderator accepts a
488 pending-moderation posts, all files attached to it which are also
489 pending approval are also approved. Similarly, when a moderator
490 rejects a pending-moderation post, all files attached to it when are
491 also pending approval are rejected.
492
493 Developer notes regarding the save-before-attach limitation:
494
495 * We cannot add the attachment form to the current post editor
496
--- www/forum.wiki
+++ www/forum.wiki
@@ -474,22 +474,23 @@
474 rendering a newer version.
475
476 Caveat: a "closed" status is not recommended because it's easy to confuse with
477 the <a href='#close-post'>"closed" tag feature</a>, which behaves considerably
478 differently and predates that "status" tag support by about three years. The
479 "closed" semantics cannot be trivially consolidated with those of "status"
480 but we reserve the right to do so at some point.
481
482 <h2 name="attachments">Attachments</h2>
483
484 As of version 2.29 users with the [./caps/index.md|'B' capability] may
485 attach files to forum posts. Files may not be attached until a forum
486 post is saved for the first time, after which an "Attach" button will
487 appear in the post when it is selected. Attached files undergo
488 moderation exactly like forum posts do. When a moderator accepts a
489 pending-moderation posts, all files attached to it which are also
490 pending approval are also approved. Similarly, when a moderator
491 rejects a pending-moderation post, all files attached to it which are
492 also pending approval are rejected.
493
494 Developer notes regarding the save-before-attach limitation:
495
496 * We cannot add the attachment form to the current post editor
497

Keyboard Shortcuts

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