From 943351b5561d153a9f56ee10a5ac48d16be622cf Mon Sep 17 00:00:00 2001 From: rboren Date: Fri, 8 Oct 2004 00:16:44 +0000 Subject: [PATCH] Check to see if any pages exist when generating page rewrite rules. Bug 345. Patch from MC_incubus. git-svn-id: http://svn.automattic.com/wordpress/trunk@1758 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-functions.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index 2b3a76f724..60164f080e 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -520,17 +520,19 @@ function generate_page_rewrite_rules() { $posts = $wpdb->get_results("SELECT ID, post_name FROM $wpdb->posts WHERE post_status = 'static'"); $page_rewrite_rules = array(); - - foreach ($posts as $post) { - // URI => page name - $uri = get_page_uri($post->ID); - - $page_rewrite_rules[$uri] = $post->post_name; + + if ($posts) { + foreach ($posts as $post) { + // URI => page name + $uri = get_page_uri($post->ID); + + $page_rewrite_rules[$uri] = $post->post_name; + } + + update_option('page_uris', $page_rewrite_rules); + + save_mod_rewrite_rules(); } - - update_option('page_uris', $page_rewrite_rules); - - save_mod_rewrite_rules(); } function the_quicktags () {