]> Sergey Matveev's repositories - public-inbox.git/commitdiff
view: handle the topic-free case properly
authorEric Wong <e@yhbt.net>
Fri, 3 Apr 2020 05:06:59 +0000 (05:06 +0000)
committerEric Wong <e@yhbt.net>
Fri, 3 Apr 2020 21:44:46 +0000 (21:44 +0000)
There may be no topics for a given timestamp range,
so don't attempt to treat `undef' as an arrayref.

lib/PublicInbox/View.pm
t/psgi_v2.t

index 89174296335ab594cfac100db4d87664d506afc4..c42654b68204c67f697278bedfba504850b8c889 100644 (file)
@@ -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} = '<pre>[No topics in range]</pre>';
                return 404;
        }
index 2c9387a496cb0d16b31019bf2297d12ecba3d834..c4f808695b000110d84d69605f5e6e42a2437d2e 100644 (file)
@@ -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();