Post slug stickiness for drafts still not quite right
|Reported by:||coffee2code||Owned by:||ryan|
Bug #531 involved post slugs being set on initial save and never updating when, while still in draft mode, a post's title changes.
The whole post slug auto-updating business was something for which I had investigated after encountering it on my own, but I ultimately concluded not to submit a bug (or patch) for this because I didn't think it would gain approval. Here's why:
The patch applied to resolve bug #531 was only half of the needed solution. The patch checked if the current $post_status was 'draft', and if so, then it updated the post slug. However, the second such check in the code, which is in the 'editpost' switch branch, needs to ALSO check $prev_status (because at the point of the check $post_status could be 'publish' for a just-published draft, so we'd need to check $prev_status to see if that was 'draft'). That fix is in the attached patch. (As it stands, the fix for bug 531 will update the post slug when going from draft -> draft, but not draft -> publish.)
There are two potential items of concern:
1.) The user can NEVER manually set the post slug. While in draft mode, WP will always sync the post slug to the post title. To resolve this, we'd probably have to store $prev_title and add a check along the lines of :
|'draft' == $post_status) && (sanitize_title($prev_title, $post_ID) == $post_name) );|
So basically if the user set the slug to be something other than the auto-slugified post title, then it shouldn't be overridden by WP.
2.) If a published post were to be set to 'draft', its title changed, then republished, the post slug would also be changed, breaking the permalink.
Due to those potential causes for concern I opted to write a plugin to keep the post slug in sync with the title, since for certain users the above may affect them when it doesn't me. However, if those issues aren't of much concern, then the attached patch should do it.
Change History (16)
11 years ago
- Owner changed from anonymous to rboren
- Status changed from new to assigned
- fixed_in_version set to 1.5.1
- Resolution changed from 10 to 20
- Status changed from assigned to closed