[wp-trac] Re: [WordPress Trac] #8526: Bad Preview Link In WordPress 2.7 With object-cache.php present

WordPress Trac wp-trac at lists.automattic.com
Sat Dec 13 02:36:32 GMT 2008


#8526: Bad Preview Link In WordPress 2.7 With object-cache.php present
----------------------------+-----------------------------------------------
 Reporter:  brianwhite      |        Owner:  anonymous
     Type:  defect          |       Status:  reopened 
 Priority:  normal          |    Milestone:           
Component:  Administration  |      Version:           
 Severity:  normal          |   Resolution:           
 Keywords:                  |  
----------------------------+-----------------------------------------------
Changes (by brianwhite):

  * status:  closed => reopened
  * resolution:  wontfix =>
  * summary:  Wordpress 2.7 RC1 Does Not Save The Post_Name (Slug) => Bad
              Preview Link In WordPress 2.7 With object-
              cache.php present

Comment:

 It turns out this is a "bug" albeit it a subtle one in WordPress.  Here's
 what I discovered after further investigation.  get_sample_permalink() in
 /wordpress/wp-admin/includes/post.php temporarily overwrites post_status,
 post_date, and post_name for the current post object and uses the updated
 object to call get_permalink().  After the call the values are restored.
 Unfortunatly, get_permalink() calls get_posts() which, in turn, calls
 wp_cache_add() which refreshes the cache with the fake data used to avoid
 an ugly permalink.  Later when, get_permalink() is called to retrieve the
 URL for the preview, the status and name in the post object in the cache
 are used which results in a "pretty" URL when drafts need "/?p=<Id>"
 format since the post_date and post_name have not yet been persisted to
 the database.

 This error only manifests itself when an object-cache.php is present in
 the /wordpress/wp-content directory.  Since the cached\ implemented by
 /wordpress/wp-includes/cache.php dies after every page load, there are no
 issues with a standard install.  The problem only occurs if someone is
 using a semi-persistent cache like memcache or APC.  The same behavior
 happened in Wordpres 2.6; however, the code to calculate the preview link
 occurred earlier in the page life cycle than the code to calculate the
 sample permalink so the "bad" data in the cached object had no visible
 effects.

 A patch which fixes the issue by reached the "correct" data is attached.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/8526#comment:4>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list