diff options
author | Yorhel <git@yorhel.nl> | 2019-11-15 18:03:42 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2019-11-15 18:03:42 +0100 |
commit | 3328d1e39868e14bd42cc341c05fdd8bd2868288 (patch) | |
tree | 03c23945f389adeff1c31d6991cfe61c317c4251 /lib/VNWeb/Discussions | |
parent | 34a2d37a7bac141aab6b0c815a17ed75d4ef858e (diff) |
Discussions::Lib: Use same WHERE clause for counting and listing
Diffstat (limited to 'lib/VNWeb/Discussions')
-rw-r--r-- | lib/VNWeb/Discussions/Lib.pm | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/VNWeb/Discussions/Lib.pm b/lib/VNWeb/Discussions/Lib.pm index 85265301..63fb80d8 100644 --- a/lib/VNWeb/Discussions/Lib.pm +++ b/lib/VNWeb/Discussions/Lib.pm @@ -17,15 +17,15 @@ our @EXPORT = qw/threadlist_/; sub threadlist_ { my %opt = @_; - my $count = $opt{paginate} && tuwf->dbVali('SELECT count(*) FROM threads t WHERE', $opt{where}); - return 0 if $opt{paginate} && !$count; - my $where = sql_and # Make sure we can only see threads we're allowed to see. auth->permBoardmod ? () : ('NOT t.hidden'), sql('NOT t.private OR EXISTS(SELECT 1 FROM threads_boards WHERE tid = t.id AND type = \'u\' AND iid =', \auth->uid, ')'), $opt{where}||(); + my $count = $opt{paginate} && tuwf->dbVali('SELECT count(*) FROM threads t WHERE', $where); + return 0 if $opt{paginate} && !$count; + my $lst = tuwf->dbPagei(\%opt, q{ SELECT t.id, t.title, t.count, t.locked, t.private, t.hidden, t.poll_question IS NOT NULL AS haspoll , }, sql_user('tfu', 'firstpost_'), ',', sql_totime('tf.date'), q{ as firstpost_date |