[wp-trac] [WordPress Trac] #18500: Not checking if index exists

WordPress Trac wp-trac at lists.automattic.com
Tue Aug 23 16:07:41 UTC 2011


#18500: Not checking if index exists
------------------------------+-----------------------------
 Reporter:  crrobi01          |      Owner:
     Type:  defect (bug)      |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  Warnings/Notices  |    Version:
 Severity:  minor             |   Keywords:  has-patch
------------------------------+-----------------------------
 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 [http://core.trac.wordpress.org/browser/trunk/wp-
 includes/post.php#L3170 #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

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18500>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list