about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2017-05-07 10:49:00 +0000
committerEric Wong <e@80x24.org>2017-05-07 10:58:08 +0000
commitfeb4a75affbe5f940116dc4f6bcc5ddb52a110b4 (patch)
tree34ab1b914e7f458cfb08db3fa9eead980960bd3f /lib
parentde243560e2caa1d19bcbf518edfaf8b016161245 (diff)
downloadpublic-inbox-feb4a75affbe5f940116dc4f6bcc5ddb52a110b4.tar.gz
Due to the asynchronous nature of SMTP, it is possible for the
root message of a thread (with no References/In-Reply-To)
to arrive last in a series.  We must preserve the thread_id
of the ghost message in this case, as we do when vivifiying
non-root ghosts.

Otherwise, this causes threads to be broken when the root
arrives last.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/Search.pm3
-rw-r--r--lib/PublicInbox/SearchIdx.pm2
2 files changed, 3 insertions, 2 deletions
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index bc2b6985..82a6e541 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -41,7 +41,8 @@ use constant {
         # 12 - change YYYYMMDD value column to numeric
         # 13 - fix threading for empty References/In-Reply-To
         #      (commit 83425ef12e4b65cdcecd11ddcb38175d4a91d5a0)
-        SCHEMA_VERSION => 13,
+        # 14 - fix ghost root vivification
+        SCHEMA_VERSION => 14,
 
         # n.b. FLAG_PURE_NOT is expensive not suitable for a public website
         # as it could become a denial-of-service vector
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index 8a529c66..e4e3c81b 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -330,7 +330,7 @@ sub link_message {
                         merge_threads($self, $tid, $ptid);
                 }
         } else {
-                $tid = $self->next_thread_id;
+                $tid = defined $old_tid ? $old_tid : $self->next_thread_id;
         }
         $doc->add_term(xpfx('thread') . $tid);
 }