]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Move nresults_postfilters recording to after POST_FILTERS stage
authorVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 14 Oct 2025 10:58:32 +0000 (11:58 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 14 Oct 2025 10:58:32 +0000 (11:58 +0100)
This fixes an issue where composite rules depending on statistics symbols
(like BAYES_SPAM) would fail to trigger. The nresults_postfilters counter
was being set too early (after COMPOSITES stage), preventing detection of
symbols added during autolearn or other post-filter processing.

Fixes #5674

src/libserver/task.c

index 0d58ad3c7b51cdd6c7f0fbcd676d0149eabfb89d..7fcf07a13bb1f8022268d8bdf2757bcb918cd301 100644 (file)
@@ -721,7 +721,6 @@ rspamd_task_process(struct rspamd_task *task, unsigned int stages)
 
        case RSPAMD_TASK_STAGE_COMPOSITES:
                rspamd_composites_process_task(task);
-               task->result->nresults_postfilters = task->result->nresults;
                break;
 
        case RSPAMD_TASK_STAGE_POST_FILTERS:
@@ -737,6 +736,11 @@ rspamd_task_process(struct rspamd_task *task, unsigned int stages)
                        !(task->flags & (RSPAMD_TASK_FLAG_LEARN_SPAM | RSPAMD_TASK_FLAG_LEARN_HAM | RSPAMD_TASK_FLAG_LEARN_CLASS))) {
                        rspamd_stat_check_autolearn(task);
                }
+
+               if (all_done) {
+                       /* Record results count after postfilters to detect if learning stages add symbols */
+                       task->result->nresults_postfilters = task->result->nresults;
+               }
                break;
 
        case RSPAMD_TASK_STAGE_LEARN: