Check that get_page_hierarchy() returns something before trying to build the verbose page rules in WP_Rewrite::page_uri_index(). Fixes #11578.

git-svn-id: https://develop.svn.wordpress.org/trunk@12520 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Westwood 2009-12-23 16:23:40 +00:00
parent f79d69c71b
commit 71847c3df1
1 changed files with 5 additions and 3 deletions

View File

@ -786,15 +786,17 @@ class WP_Rewrite {
//get pages in order of hierarchy, i.e. children after parents
$posts = get_page_hierarchy($wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'page'"));
// If we have no pages get out quick
if ( !$posts )
return array( array(), array() );
//now reverse it, because we need parents after children for rewrite rules to work properly
$posts = array_reverse($posts, true);
$page_uris = array();
$page_attachment_uris = array();
if ( !$posts )
return array( array(), array() );
foreach ($posts as $id => $post) {
// URL => page name
$uri = get_page_uri($id);