Make WordPress Core

Opened 10 years ago

Closed 8 years ago

#7915 closed enhancement (worksforme)

Links to pages that are children of drafts are broken

Reported by: stevish Owned by: ryan
Milestone: Priority: low
Severity: minor Version: 2.7
Component: Permalinks Keywords:
Focuses: Cc:


Assume you have a page called "Parent" that is saved as a draft. Then assume that you write a page called "Child", set it as a child of "Parent", and publish it. The permalink that will be generated for "Child" will be http://example.com//child instead of http://example.com/parent/child. And clicking on said link (or typing it into your browser's address bar) will produce a 404.

Another interesting oddity is if you try to go manually to http://example.com/child, it will redirect you to http://example.com//child and produce a 404.

This is definitely a minor bug, and some may not even consider it a bug. The situation during which this would be a problem is if you are making a page that has links to all its child pages, and you don't want to publish this main page until you're sure all the links work properly. In that case (which happens to have been my case), you will then spend 2 hours digging through forums and messing around with permalinks, trying to figure out why these links aren't working.

It's a rare situation, but it can be a pretty time consuming little problem.

Change History (12)

#1 @markjaquith
10 years ago

  • Priority changed from normal to low
  • Severity changed from normal to minor

How about saving the parent page as private? That'll give it a permalink, but keep it non-public.

We're likely not going to fix this, but we shouldn't be generating links for published pages that don't work. In the case that a page's parent isn't published, maybe we should just use the temporary ?page_id=123&preview=true URL.

#2 @markjaquith
10 years ago

Clarification, not going to fix this in a way that'll make the anticipated URLs work... because without a published parent, we don't know what the parent URL is going to be (even if you do know...)

#3 @DD32
10 years ago

The other option would be to prevent publishing if any of the parent pages are unpublished?

#4 @markjaquith
10 years ago

I think the workflow here is to create a parent draft, create children (and publish those) and then when you're satisfied with your Page family, you publish the parent (and make all the children discoverable too). If we prevented publishing children of published parents, you'd lose the ability to publish an entire family with one click, which I think is pretty powerful.

#5 @stevish
10 years ago

Maybe if the user publishes a child of an unpublished parent, WordPress could treat it as unpublished (and include a message when the page is published to the tune of "The parent of this page is unpublished. This page will be published as soon as its parent is"). Then as soon as the parent is published, WP would look for any children with the "pending automatic publication" property (or whatever), and then publish them.

#6 @westi
10 years ago

I think the most we should probably do here is to warn that the parent is unpublished.

The workflow that Mark describes is important to peserve.

Maybe an extra message in the notice box when you publish the post with a link to the parent?

#7 @Denis-de-Bernardy
9 years ago

  • Keywords dev-feedback added
  • Version set to 2.7

I like the pending idea. how about this workflow:

  • if any parent is draft or pending, set the status to future.
  • in cron, check if a page's parents are all published before actually publishing
  • on publish the parent page, publish all children with a status of future

that way, you end up using existing WP workflow to fix the issue. the post remains around to be browsed by editors, but isn't available to the public.

#8 @ryan
9 years ago

  • Milestone changed from 2.8 to Future Release

#9 @Denis-de-Bernardy
9 years ago

  • Component changed from General to Permalinks
  • Owner changed from anonymous to ryan

#10 @Denis-de-Bernardy
9 years ago

  • Type changed from defect (bug) to enhancement

#11 @Denis-de-Bernardy
9 years ago

  • Keywords needs-patch added; dev-feedback removed

#12 @johnbillion
8 years ago

  • Keywords needs-patch removed
  • Milestone Future Release deleted
  • Resolution set to worksforme
  • Status changed from new to closed

worksforme as we've had a change in behaviour somewhere along the line. Published pages are always published and viewable irrespective of their descendants' status, and permalinks work as expected and are no longer broken.

A published page called 'child' with a draft parent page called 'parent' will generate a permalink of example.com/parent/child and it's accessible as expected. The parent page at example.com/parent will generate a 404 for visitors. I think this is expected behaviour.

(Note: Mark's comments about workflow are valid but I'm not sure this workflow is common enough to warrant a change IMO. Probably plugin territory if people want that sort of behaviour.)

Note: See TracTickets for help on using tickets.