WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#18500 closed defect (bug) (duplicate)

Not checking if index exists

Reported by: crrobi01 Owned by:
Milestone: Priority: normal
Severity: minor Version:
Component: Warnings/Notices Keywords: has-patch
Focuses: Cc:

Description

While loading a child page at the url (http://wp.localhost/videos/latest-videos/) I got the following notices:
Notice: Undefined index: 0 in /home/www/wordpress/htdocs/wp-includes/post.php on line 3174
Notice: Trying to get property of non-object in /home/www/wordpress/htdocs/wp-includes/post.php on line 3170
Notice: Trying to get property of non-object in /home/www/wordpress/htdocs/wp-includes/post.php on line 3177

The loop at #3170 should be like:

while ( $parent_page->ID != 0 ) {
	$count++;
	if ( $parent_page->post_name != $revparts[ $count ] ) 
		break;
	elseif ( $parent_page->post_parent == 0 ) 
		$parent_page = (object) array('ID' => 0, 'post_name' => 0, 'post_parent' => 0);
	else 
		$parent_page = $pages[ $parent_page->post_parent ];
}				

Or you could change the elseif line to

elseif ( ! isset( $pages[ $parent_page->post_parent ] ) )

if you want to be more strict about it

Change History (1)

#1 @dd32
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.