WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 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:

Description

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)

comment:1 markjaquith5 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.

comment:2 markjaquith5 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...)

comment:3 DD325 years ago

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

comment:4 markjaquith5 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.

comment:5 stevish5 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.

comment:6 westi5 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?

comment:7 Denis-de-Bernardy5 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.

comment:8 ryan5 years ago

  • Milestone changed from 2.8 to Future Release

comment:9 Denis-de-Bernardy5 years ago

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

comment:10 Denis-de-Bernardy5 years ago

  • Type changed from defect (bug) to enhancement

comment:11 Denis-de-Bernardy5 years ago

  • Keywords needs-patch added; dev-feedback removed

comment:12 johnbillion4 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.