[wp-trac] [WordPress Trac] #39321: Issue with get_permalink when using wp_update_post() and %author% is part of your permalink

WordPress Trac noreply at wordpress.org
Fri Dec 23 02:58:05 UTC 2016


#39321: Issue with get_permalink when using wp_update_post() and %author% is part
of your permalink
--------------------------+------------------------------
 Reporter:  mauteri       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:  4.7
 Severity:  normal        |  Resolution:
 Keywords:  dev-feedback  |     Focuses:
--------------------------+------------------------------
Changes (by boonebgorges):

 * keywords:   => dev-feedback


Comment:

 Good catch, @mauteri.

 It seems that this specific set of circumstances - a `revision` having
 `post_author=0` - only happens when programatically updating posts. When a
 post is updated through the interface, there's a logged-in user, and that
 user is assigned to the revision. This dates back to [8480]; see #7317.

 Aside from programatically-created revisions, it's possible to have posts
 with `post_author=0` in other ways. So I think there are a couple separate
 questions here:

 1. What do we expect the permalink of a `revision` to look like? More
 specifically, are there places in core or in plugins where we expect it to
 be the same as the parent post? At the moment, this is not the case, at
 least when `%author%` is part of the permastruct: Different revisions of
 the same post could have different authors. Your change would make this
 worse, since the structure of the URL would be different for authorless
 revisions: `example.com/authorname/postname` vs `example.com/postname`.
 Perhaps revisions should always have permalinks of the form `?p=123`, as
 is the case with `draft`, `pending`, `auto-draft`, and `future`.

 2. What do we expect the permalink of an authorless post to look like, if
 `%author%` is part of the permalink structure? `post_author` can be set to
 0 in cases other than when the post is a `revision`. Simply excluding the
 `%author%` chunk seems like it could introduce weird bugs. Should we have
 a dummy slug of some sort? Or maybe we should revert to non-pretty
 permalinks `?p=123` when no author is available?

 As a workaround, try providing a `post_author` when calling
 `wp_update_post()`.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39321#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list