From cacc32740c470079e7b653ab48f22d4180cdfa15 Mon Sep 17 00:00:00 2001 From: evazion Date: Thu, 23 Apr 2020 15:03:38 -0500 Subject: [PATCH] posts: fix missing pages for members using hide_deleted_posts option. Bug: If a Member had the hide_deleted_posts option turned on and did a two tag search, no pages would show up. Cause: The hide_deleted_posts option implicitly adds the -status:deleted tag, but this tag wasn't considered a free metatag, so this caused Post.fast_count to fail and return zero because the search was treated as a three tag search. ref: https://danbooru.donmai.us/forum_topics/16829 --- config/danbooru_default_config.rb | 2 +- test/unit/post_test.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb index 0762e1edc..2dab0f379 100644 --- a/config/danbooru_default_config.rb +++ b/config/danbooru_default_config.rb @@ -109,7 +109,7 @@ module Danbooru # Return true if the given tag shouldn't count against the user's tag search limit. def is_unlimited_tag?(term) - term.type == :metatag && term.name.in?(%w[status rating limit]) + term.type == :metatag && term.name.in?(%w[-status status rating limit]) end # After this many pages, the paginator will switch to sequential mode. diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index c4e412199..ddcb73e7a 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -1983,6 +1983,13 @@ class PostTest < ActiveSupport::TestCase Cache.expects(:put).with(Post.count_cache_key("aaa score:42"), 1, 180) Post.fast_count("aaa score:42") end + + should "work with the hide_deleted_posts option turned on" do + user = create(:user, hide_deleted_posts: true) + as(user) do + assert_equal(1, Post.fast_count("aaa score:42")) + end + end end context "a blank search" do