[wp-trac] [WordPress Trac] #9180: Query clears posts, impossible to see public content on permalink page

WordPress Trac wp-trac at lists.automattic.com
Thu Feb 19 19:11:18 GMT 2009


#9180: Query clears posts, impossible to see public content on permalink page
--------------------------+-------------------------------------------------
 Reporter:  MrPeteH       |       Owner:  anonymous
     Type:  defect (bug)  |      Status:  new      
 Priority:  normal        |   Milestone:  2.8      
Component:  General       |     Version:           
 Severity:  major         |    Keywords:           
--------------------------+-------------------------------------------------
 Various tools such as wp-sentry enable public home page view of above-the-
 fold or excerpt portions of posts.
 Unfortunately, due to a bug in query.php, the same content cannot be
 viewed on the permalink page for the same posts. Instead, non-logged-in
 users are told they are visiting an invalid or invisible page... which
 should be incorrect.

 The fix is quite simple in wp-includes/query.php line 2274.

 Current code conditionally clears the posts[] array:
 {{{
 if ( ! is_user_logged_in() ) {
   // User must be logged in to view unpublished posts.
   $this->posts = array();
   } else {
    ... (code that deals with non-public posts for logged-in users)
   }
 }}}

 This can be simplified by removing the condition and array-clearing:
 {{{
   // Handle unpublished posts for all users.
    ... (code that deals with non-public posts for logged-in users)
 }}}

 I have tested this extensively with a variety of scenarios. It works
 perfectly. Essentially, the code that knows how to determine post
 visibility already handles private/future/draft posts correctly. There's
 no need to arbitrarily delete the posts information!

 The benefit of this simple fix:
 * Whatever a user (logged in or not) can see on the home page is the same
 info they see on a post-specific page.
 * MUCH less confusing than the current situation, where a non-logged in
 user following a link is given a message that there's NOTHING to see (when
 they know there IS something to see -- it's available right on the home
 page!)

 This is a killer for significant users of public/private content.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/9180>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list