#26901 closed defect (bug) (fixed)
Warning line 1059 in post-template.php
| Reported by: | tunjic | Owned by: | wonderboymusic |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.1 |
| Component: | Posts, Post Types | Version: | 3.5 |
| Severity: | minor | Keywords: | has-patch commit |
| Cc: | Focuses: | multisite |
Description (last modified by )
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 ) )
Attachments (1)
Change History (8)
#4
@
12 years ago
- Keywords has-patch added
- Milestone Awaiting Review → 4.1
- Version 3.8 → 3.5
Thanks for the bug report @tunjic.
It seems this can happen if the walker gets a list of pages and one does not exist. We actually used to check for $_current_page->ancestors here before some other cleanup in [21559] got rid of it. I'm not sure that this is specifically multisite related, but the use of switch_to_blog() could be resulting in the query of some post IDs that exist on one site and not the other.
26901.diff adds a check to make sure we didn't receive null back from get_post(). We do the same thing a bit farther down before looking for a post parent.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
With 3.9, this has moved to line 1252. /wp-includes/post-template.php on line 1252,