From 05e19b1cde7ed005b2cd151e4cd64f7542298b20 Mon Sep 17 00:00:00 2001 From: westi Date: Wed, 23 Dec 2009 16:23:40 +0000 Subject: [PATCH] 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: http://svn.automattic.com/wordpress/trunk@12520 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/rewrite.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index 4c8d9e68c..b2aebe199 100644 --- a/wp-includes/rewrite.php +++ b/wp-includes/rewrite.php @@ -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);