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
This commit is contained in:
@@ -109,7 +109,7 @@ module Danbooru
|
|||||||
|
|
||||||
# Return true if the given tag shouldn't count against the user's tag search limit.
|
# Return true if the given tag shouldn't count against the user's tag search limit.
|
||||||
def is_unlimited_tag?(term)
|
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
|
end
|
||||||
|
|
||||||
# After this many pages, the paginator will switch to sequential mode.
|
# After this many pages, the paginator will switch to sequential mode.
|
||||||
|
|||||||
@@ -1983,6 +1983,13 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
Cache.expects(:put).with(Post.count_cache_key("aaa score:42"), 1, 180)
|
Cache.expects(:put).with(Post.count_cache_key("aaa score:42"), 1, 180)
|
||||||
Post.fast_count("aaa score:42")
|
Post.fast_count("aaa score:42")
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context "a blank search" do
|
context "a blank search" do
|
||||||
|
|||||||
Reference in New Issue
Block a user