[wp-trac] Re: [WordPress Trac] #8022: non-DISTINCT query in get_archives for postbypost

WordPress Trac wp-trac at lists.automattic.com
Tue Feb 17 19:21:25 GMT 2009


#8022: non-DISTINCT query in get_archives for postbypost
----------------------------------------+-----------------------------------
 Reporter:  kevinB                      |        Owner:  anonymous
     Type:  defect (bug)                |       Status:  reopened 
 Priority:  normal                      |    Milestone:  2.8      
Component:  Template                    |      Version:  2.7      
 Severity:  normal                      |   Resolution:           
 Keywords:  archives,postbypost,filter  |  
----------------------------------------+-----------------------------------

Comment(by kevinB):

 I'm sorry I dragged "comments" into this conversation by accidentally
 using that word in a previous entry.  My concern here is strictly with the
 listing of posts by the function wp_get_archives, and the possibility of
 filtering that list by post category or other one-to-many relationship.

 I labeled this as a defect rather than feature request since the
 getarchives_join filter is already applied to the postbypost archive type,
 but joining on categories (a likely usage) causes duplicate entries in the
 end user's archives listing '''if a post is in more than one joined
 category'''.

 I maintain a plugin ([http://agapetry.net/news/introducing-role-scoper/])
 which imposes content-specific permissions.  I do this via JOIN and IN
 clauses on the term_relationships table (for category-specific roles) and
 also on my own user2role2object table (for post/page-specific roles).

 For the most part, WordPress provides all the hooks I need to pull this
 off.  For wp_get_archives, I have the getarchives_join and
 getarchives_where filters.  For the same reasons you cited above, my JOIN
 clauses would generate duplicate archive listings if the post is in more
 than one user-readable category.  Existing DISTINCT clauses in the
 monthly, yearly, weekly and daily archive types prevent duplicates.
 However, the query for postbypost archive uses a "SELECT *" query.  I want
 to filter that to "SELECT DISTINCT $wpdb->posts.*"

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/8022#comment:9>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list