[wp-trac] [WordPress Trac] #22867: Function wp_get_nav_menu_items - Fatal error - Wordpress 3.5 and earlier
WordPress Trac
noreply at wordpress.org
Tue Dec 11 23:27:45 UTC 2012
#22867: Function wp_get_nav_menu_items - Fatal error - Wordpress 3.5 and earlier
-----------------------------+--------------------------
Reporter: sporky | Type: defect (bug)
Status: new | Priority: normal
Milestone: Awaiting Review | Component: General
Version: 3.5 | Severity: critical
Keywords: |
-----------------------------+--------------------------
The function wp_get_nav_menu_items fails when a "Page" type post has been
added to a menu.
This is a fresh install of Wordpress 3.5, using the "Sample Page" page
added to a menu called "main_menu". This menu has no other menu options
added to it. This bug also occurs in earlier versions of Wordpress.
Sample PHP Code:
<?php
$menu_name = 'main_menu';
$nav_menu_object = wp_get_nav_menu_object($menu_name);
$menu_id = $nav_menu_object->term_id;
$menu_items = wp_get_nav_menu_items($menu_id); <<--- Error occurs here
?>
The following error occurs:
Fatal error: Call to a member function get_page_permastruct() on a non-
object in C:\xampp\htdocs\lchs4\wp-includes\link-template.php on line 271
This occurs in the following area of code:
function _get_page_link( $post = false, $leavename = false, $sample =
false ) {
global $wp_rewrite;
$post = get_post( $post );
$draft_or_pending = in_array( $post->post_status, array( 'draft',
'pending', 'auto-draft' ) );
$link = $wp_rewrite->get_page_permastruct(); <--- happens here
Essentially, the variable $wp_rewrite shows as <Uninitialized> when viewed
in xdebug using Eclipse.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/22867>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list