From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id CD5D91FAFA for ; Tue, 6 Mar 2018 08:42:43 +0000 (UTC) From: "Eric Wong (Contractor, The Linux Foundation)" To: meta@public-inbox.org Subject: [PATCH 23/34] nntp: fix NEWNEWS command Date: Tue, 6 Mar 2018 08:42:31 +0000 Message-Id: <20180306084242.19988-24-e@80x24.org> In-Reply-To: <20180306084242.19988-1-e@80x24.org> References: <20180306084242.19988-1-e@80x24.org> List-Id: I guess nobody uses this command (slrnpull does not), and the breakage was not noticed until I started writing new tests for multi-MID handling. Fixes: 3fc411c772a21d8f ("search: drop pointless range processors for Unix timestamp") --- lib/PublicInbox/NNTP.pm | 2 +- lib/PublicInbox/Search.pm | 14 ++++++++++++++ t/nntpd.t | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm index 895e502..fb65ddc 100644 --- a/lib/PublicInbox/NNTP.pm +++ b/lib/PublicInbox/NNTP.pm @@ -336,7 +336,7 @@ sub cmd_newnews ($$$$;$$) { long_response($self, 0, long_response_limit, sub { my ($i) = @_; my $srch = $srch[0]; - my $res = $srch->query($ts, $opts); + my $res = $srch->query_ts($ts, $opts); my $msgs = $res->{msgs}; if (my $nr = scalar @$msgs) { more($self, '<' . diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index 802984b..4dc2747 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -330,6 +330,20 @@ sub query_xover { _do_enquire($self, $query, $opts); } +sub query_ts { + my ($self, $ts, $opts) = @_; + my $qp = $self->{qp_ts} ||= eval { + my $q = Search::Xapian::QueryParser->new; + $q->set_database($self->{skel} || $self->{xdb}); + $q->add_valuerangeprocessor( + Search::Xapian::NumberValueRangeProcessor->new(TS)); + $q + }; + my $query = $qp->parse_query($ts, QP_FLAGS); + $opts->{enquire} = enquire_skel($self); + _do_enquire($self, $query, $opts); +} + sub lookup_skeleton { my ($self, $mid) = @_; my $skel = $self->{skel} or return lookup_message($self, $mid); diff --git a/t/nntpd.t b/t/nntpd.t index ea0d293..de781d7 100644 --- a/t/nntpd.t +++ b/t/nntpd.t @@ -228,6 +228,8 @@ EOF is_deeply($n->xhdr(qw(list-id 1-)), {}, 'XHDR on invalid header returns empty'); + my $mids = $n->newnews(0, '*'); + is_deeply($mids, [''], 'NEWNEWS works'); { my $t0 = time; my $date = $n->date; -- EW