Make WordPress Core

#37423 closed defect (bug) (fixed)

Permalink for pending post - get_sample_permalink_html bug

Reported by: knutsp Owned by: jorbin
Milestone: 4.7 Priority: normal
Severity: major Version: 4.4
Component: Permalinks Keywords: has-patch dev-feedback
Focuses: ui, administration Cc:


Steps to reproduce:

  • Create a new post, edit Status to Pending Review and press Save as Pending
  • After saved, observe the Permalink field

Expected, either:

  • No permalink yet (but a draft displays a working preview link)
  • A working link for preview post, and that the displayed URL and the actual href value on it is equal


  • Permalink is displayed as https://example.com/2016/my-post/ (gives status 404)
  • Permalink href is actually: https://example.com/2016// (shows the yearly archive)

(Permalink settings: /%year%/%postname%/)

Attachments (3)

37423.diff (1016 bytes) - added by knutsp 22 months ago.
Makes the actual sample permalink for pending posts valid as preview link
permalink.png (51.2 KB) - added by knutsp 22 months ago.
Screenshot - invalid sample permalink
37423.test.diff (1.0 KB) - added by enshrined 21 months ago.
Test for 47423.diff

Download all attachments as: .zip

Change History (10)

#1 @knutsp
22 months ago

As a draft the permalink field displays https://example.com/2016/my-post/ and links to https://example.com/?p=123&preview=true (correct).

So it seems the displayed URL is meant to be a kind of permalink suggestion. Ok, but it's a "faked" link and feels strange and buggy. But the actual link must work, also for pending posts.

Last edited 22 months ago by knutsp (previous) (diff)

22 months ago

Makes the actual sample permalink for pending posts valid as preview link

#2 @knutsp
22 months ago

  • Keywords has-patch dev-feedback needs-unit-tests added
  • Version set to 4.4

37423.diff just fixes the href part and let's you preview the post when clicking. The displayed link, however, still shows an invalid permalink / preview link for posts not yet given a post_name.

I think this bug was introduced in 4.4 when this part of the screen was redesigned a bit.

Please help get this fixed.

#3 @knutsp
22 months ago

  • Component changed from Editor to Permalinks
  • Focuses ui added
  • Severity changed from normal to major
  • Summary changed from Permalink for pending post - editor bug to Permalink for pending post - get_sample_permalink_html bug

Anyone to take a look at this?

22 months ago

Screenshot - invalid sample permalink

#4 @knutsp
21 months ago

Hello from the other side! (Adele)

I report a bug, then try my best to make patch, but no comments or anything. I'm now feeling this is ignored. Is there some active maintainer for the Permalinks component? Or @helen? Do you want bugs reported from users?

This ticket needs a milestone, at least. Or say it's not a bug at all.

#5 @SergeyBiryukov
21 months ago

  • Milestone changed from Awaiting Review to 4.7

21 months ago

Test for 47423.diff

#6 @enshrined
21 months ago

  • Keywords needs-unit-tests removed

I've attached a test for posts that contain no post_name to make sure they instead use the preview link rather than a broken permalink. This test passes with the previous patch (37423.diff) but fails without.

Also realised my message for the test had the wrong ticket number in it, apologies.

#7 @jorbin
21 months ago

  • Owner set to jorbin
  • Resolution set to fixed
  • Status changed from new to closed

In 38572:

Permalinks: Ensure Pending Review Posts permalink posts link to the draft

[34670] made the displayed permalink clickable. For posts that were pending review, the permalink wasn't being properly generated so the link wouldn't go to the preview.

Props knutsp, enshrined.
Fixes #37423.

Note: See TracTickets for help on using tickets.