[wp-trac] [WordPress Trac] #26901: Warning line 1059 in post-template.php

WordPress Trac noreply at wordpress.org
Sat Feb 1 20:00:20 UTC 2014


#26901: Warning line 1059 in post-template.php
--------------------------+------------------------------
 Reporter:  tunjic        |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:  3.8
 Severity:  minor         |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------
Description changed by ocean90:

Old description:

> Error produced in multisite (sub-directory) when combining switch_to_blog
> and wp_list_pages.
>
> See this support thread: http://wordpress.org/support/topic/post-
> template-1059-warning-object?replies=15
>
> Here is the page that produces the PHP warning in my server error logs:
> http://www.rockbrookcamp.com/sitemap/  It is an html sitemap with a
> custom page template.  The code for that template is here:
> https://github.com/tunjic/rbc-sitemap-template
>
> Ipstenu suggested this might be related to
> https://core.trac.wordpress.org/ticket/23290
>
> The following edit of wp-includes/post-template.php (suggested by
> Rasmataz in the support thread above) '''does''' remove the error:
>
> "wp-includes/post-template.php was throwing a warning in the start_el
> function of class Walker at line 1059 because $_current_page results in
> NULL.
>
> I worked around the issue by changing line 1059 as follows:"
>
> {{{
> FROM: if (in_array( $page->ID, $_current_page->ancestors ) )
>
> TO: if (is_object($_current_page) && in_array( $page->ID,
> $_current_page->ancestors ) )
> }}}

New description:

 Error produced in multisite (sub-directory) when combining switch_to_blog
 and wp_list_pages.

 See this support thread: http://wordpress.org/support/topic/post-
 template-1059-warning-object?replies=15

 Here is the page that produces the PHP warning in my server error logs:
 http://www.rockbrookcamp.com/sitemap/  It is an html sitemap with a custom
 page template.  The code for that template is here:
 https://github.com/tunjic/rbc-sitemap-template

 Ipstenu suggested this might be related to #23290

 The following edit of wp-includes/post-template.php (suggested by Rasmataz
 in the support thread above) '''does''' remove the error:

 "wp-includes/post-template.php was throwing a warning in the start_el
 function of class Walker at line 1059 because $_current_page results in
 NULL.

 I worked around the issue by changing line 1059 as follows:"

 {{{
 FROM: if (in_array( $page->ID, $_current_page->ancestors ) )

 TO: if (is_object($_current_page) && in_array( $page->ID,
 $_current_page->ancestors ) )
 }}}

--

--
Ticket URL: <https://core.trac.wordpress.org/ticket/26901#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list