Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Posts::get() counts do not work with tag pages with multiple tags #477

Open
Konzertheld opened this issue Feb 19, 2013 · 4 comments
Open

Comments

@Konzertheld
Copy link
Member

Original title (see comments): Pagination for multiple tag pages not based on actual number of posts

yourblog.tld/tag/foo bar will show you the posts tagged with foo and bar, but the pagination will offer you more pages then there are actually, even more than one of the tags would have. For single tags, the pagination pages are correct.

This is for both 0.9 and 0.10.

@mikelietz and I were able to work it out so far:

When multiple tags are passed to Posts::get() as vocabulary parameter tags:all:term, as the tag page (act_display_tag) does, they are used in the JOIN statement that joins the term table in an ON ... IN (foo, bar, blablabla). An additional HAVING COUNT(*) = X filters the result so only the posts that have all terms are returned. Unfortunately, HAVING clauses are removed when COUNT is used in the SELECT statement (they would not work anyway). So we need to find a different way for either counts or vocabulary selections.

@Konzertheld
Copy link
Member Author

This goes back to Posts::count_all() returning the wrong number of posts when called by Theme::theme_page_selector().

@Konzertheld
Copy link
Member Author

And that again goes back to the problem that adding the count parameter to a Posts::get() kills the vocabulary parameter.

@Konzertheld
Copy link
Member Author

Ok, it does not. But while the tag page ANDs the tags (aka posts are selected on an AND basis), the Posts::get() for count ORs them.

@Konzertheld
Copy link
Member Author

Figured it out with @mikelietz that it's in the SQL: Tags are ORed (the term table is joined ON term IN (foo, bar, crap)) and then the posts are reduced with HAVING COUNT(*) = number of tags. That does not work for counts because HAVING clauses are removed for counts.

http://drunkenmonkey.org/irc/habari/2013-09-27#T00-09-08

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant