Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#18500 closed defect (bug) (duplicate)

Not checking if index exists

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

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
15 years ago

  • Milestone Awaiting Review
  • Resolution → duplicate
  • Status new → closed
Note: See TracTickets for help on using tickets.