Opened 9 years ago
Closed 9 years ago
#32954 closed defect (bug) (fixed)
"View post" link should not change when sample permalink changes
Reported by: | johnbillion | Owned by: | johnbillion |
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | 4.2 |
Component: | Posts, Post Types | Keywords: | has-patch |
Focuses: | administration | Cc: |
Description
This is a follow-up to #16477 which was fixed in 3.9 but has re-appeared.
To reproduce:
- Go to edit a post
- Change the permalink
- Click on "View post" and you get a 404 because the href has been changed to the new sample permalink but the post hasn't been updated yet
The "View post" link should always point to the permalink of the currently saved post.
r27508 was the initial fix. Need to find out where the regression occurred.
Attachments (1)
Change History (5)
#2
@
9 years ago
- Keywords has-patch added; needs-patch removed
The reasoning behind [32002] was to make View Post point to a pretty permalink for scheduled posts; get_permalink()
only returns a pretty permalink for posts with post_status=publish
. The error in that changeset was to trust the $post_name
variable, which is the *updated* post slug, rather than the one stored in the database. As you suggest, the saved slug should always be used.
See 32954.diff, where I suggest using $post->post_name
rather than $post_name
in the str_replace()
that generates the pretty permalink. I put in a special case if ( 'publish' === $post->post_status ) { $pretty_permalink = get_permalink( $post ); }
; I'm pretty sure this is equivalent to the str_replace()
in the else
clause, but perhaps it makes it a bit clearer what's going on.
@johnbillion Does this seem right to you?
Broken in r32002