[wp-trac] [WordPress Trac] #12473: _wp_old_slug not updated when updating post_name via quick edit

WordPress Trac wp-trac at lists.automattic.com
Tue Mar 2 17:01:41 UTC 2010


#12473: _wp_old_slug not updated when updating post_name via quick edit
--------------------------+-------------------------------------------------
 Reporter:  mbarklund     |       Owner:             
     Type:  defect (bug)  |      Status:  new        
 Priority:  low           |   Milestone:  Unassigned 
Component:  Quick Edit    |     Version:  2.9.2      
 Severity:  major         |    Keywords:  wp-old-slug
--------------------------+-------------------------------------------------
 I had a hard time tracking down the flow of data from post update to
 recording _wp_old_slug in wp_postmeta but tracked the issue down to:

 When a post is edited via the "normal" full-featured form, the previous
 slug (post_name) is included in the hidden form field "wp-old-slug" via
 template.php:wp_remember_old_slug() called from action in default-
 filters.php:add_action('edit_form_advanced', 'wp_remember_old_slug');

 When this field is present in the post data, the action handler wp-
 includes/post.php:wp_check_for_changed_slugs() makes sure to record the
 old slug in wp_postmeta, if different from the new slug.

 But this field, {{{$_POST['wp-old-slug']}}}, is not present when updating
 the post via Quick Edit (form rendered via template.php:inline_edit_row).
 This form does not have a wp-old-slug hidden field, neither do the inline-
 edit-data rendered for each individual row and the inline-edit-post.js
 knows nothing about such a variable. This extra variable should be added
 in all three places as far as I can see, and then it would probably work
 correctly "out of the box" without further hacks.

 One hack that does not require it to be added to the inline-post-data
 (rendered in template.php:get_inline_data) as it is initially identical to
 post_name, instead requires that inline-edit-post.js just transfers
 post_name to two input fields in the general form (one of them with name
 =wp-old-slug and type=hidden).

 And one completely other possibility is adding {{{$_POST['wp-old-slug']}}}
 in admin-ajax.php when handling action 'inline-edit'/'inline-save' by
 reading current post_name from DB and if different from submitted, store
 old post_name as {{{$_POST['wp-old-slug']}}}.

 This bug caused great annoyances for me, as I changed my slug naming
 scheme at some point and edited a bunch of posts via Quick Edit - now
 these posts do not answer on the previous URL's as _wp_old_slug was not
 recorded for these.

 Finally, somewhat related to this, I find that _wp_old_slug works very
 inconsistently. It seems to be able to save multiple old slugs, but that
 sometimes fails. Haven't been able to pinpoint when it does and when it
 doesn't, but have just experienced a lot of inconsistency.

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


More information about the wp-trac mailing list