WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 3 hours ago

#15963 assigned defect (bug)

Don't try to add orphaned pages' parents' slugs to the page URL

Reported by: filosofo Owned by: chriscct7
Milestone: 4.4 Priority: normal
Severity: normal Version: 3.1
Component: Posts, Post Types Keywords: has-patch
Focuses: Cc:

Description

If a page becomes orphaned---in other words, if a page points to a parent object that doesn't exist any more---get_page_uri() doesn't sanity check that the parent object actually exists.

Patch does the check without any extra work, by moving stuff around.

Attachments (6)

avoid-notice-on-orphaned-pages.15963.diff (748 bytes) - added by filosofo 5 years ago.
15963.2.diff (429 bytes) - added by MikeHansenMe 3 years ago.
checks the status of the parent page before adding it to uri
15963.3.diff (438 bytes) - added by SergeyBiryukov 3 years ago.
Original patch, refreshed
15963.3.alt.diff (447 bytes) - added by SergeyBiryukov 3 years ago.
Same as 15963.2.diff, with proper formatting
15963.4.diff (491 bytes) - added by MikeHansenMe 3 hours ago.
15963.4.2.diff (505 bytes) - added by chriscct7 3 hours ago.

Download all attachments as: .zip

Change History (14)

@MikeHansenMe3 years ago

checks the status of the parent page before adding it to uri

comment:1 @MikeHansenMe3 years ago

  • Keywords needs-testing 2nd-opinion added

This seems to fix the problem in version (3.5-alpha-21751).

Code used to test:
<?php
$uri = get_page_uri(get_the_ID());
echo '<a href="'. $uri .'">The Page</a>';
?>
The output :
<a href="sample-page/thistoo">The Page</a>

My main concern is I was not using permalinks...
However the patch does show "thistoo" if I delete "Sample Page".

Last edited 3 years ago by MikeHansenMe (previous) (diff)

@SergeyBiryukov3 years ago

Original patch, refreshed

@SergeyBiryukov3 years ago

Same as 15963.2.diff, with proper formatting

comment:2 @MikeHansenMe3 years ago

  • Cc mdhansen@… added

comment:3 @nacin20 months ago

  • Component changed from General to Post Types

comment:4 @chriscct73 hours ago

  • Keywords needs-refresh added; 3.2-early needs-testing 2nd-opinion removed
  • Milestone changed from Future Release to 4.4
  • Owner set to chriscct7
  • Status changed from new to assigned

@MikeHansenMe3 hours ago

comment:5 @MikeHansenMe3 hours ago

  • Keywords needs-refresh removed

@chriscct73 hours ago

comment:6 @chriscct73 hours ago

Careful there @MikeHansenMe with those string comparisons ;)

comment:7 @MikeHansenMe3 hours ago

looks like 15963.3.alt.diff also had that issue.. My bad. Nice catch!

comment:8 @slackbot3 hours ago

This ticket was mentioned in Slack in #meta by chriscct7. View the logs.

Note: See TracTickets for help on using tickets.