From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 5279E1F487 for ; Fri, 3 Apr 2020 05:06:59 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] view: handle the topic-free case properly Date: Fri, 3 Apr 2020 05:06:59 +0000 Message-Id: <20200403050659.17336-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: There may be no topics for a given timestamp range, so don't attempt to treat `undef' as an arrayref. --- lib/PublicInbox/View.pm | 2 +- t/psgi_v2.t | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 89174296..c42654b6 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -1056,7 +1056,7 @@ sub acc_topic { # walk_thread callback sub dump_topics { my ($ctx) = @_; my $order = delete $ctx->{order}; # [ ds, subj1, subj2, subj3, ... ] - if (!@$order) { + unless ($order) { $ctx->{-html_tip} = '
[No topics in range]
'; return 404; } diff --git a/t/psgi_v2.t b/t/psgi_v2.t index 2c9387a4..c4f80869 100644 --- a/t/psgi_v2.t +++ b/t/psgi_v2.t @@ -250,6 +250,8 @@ test_psgi(sub { $www->call(@_) }, sub { is($old->content, 'old', 'got expected old content'); is($new->content, 'new', 'got expected new content'); } + $res = $cb->(GET('/v2test/?t=1970'.'01'.'01'.'000000')); + is($res->code, 404, '404 for out-of-range t= param'); }); done_testing();