Cache rewrite rules. Add WP_Rewrite::flush_rules(). fixes #2155
git-svn-id: http://svn.automattic.com/wordpress/trunk@3373 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
81f0c504cd
commit
305a286ce1
|
@ -171,7 +171,7 @@ $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comm
|
|||
// First Page
|
||||
|
||||
$wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status, to_ping, pinged, post_content_filtered) VALUES ('1', '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(__('about'))."', '$now', '$now_gmt', 'static', '', '', '')");
|
||||
generate_page_rewrite_rules();
|
||||
$wp_rewrite->flush_rules();
|
||||
|
||||
// Set up admin user
|
||||
$random_password = substr(md5(uniqid(microtime())), 0, 6);
|
||||
|
|
|
@ -76,8 +76,6 @@ if ( isset($_POST) ) {
|
|||
$permalink_structure = get_settings('permalink_structure');
|
||||
$category_base = get_settings('category_base');
|
||||
|
||||
generate_page_rewrite_rules();
|
||||
|
||||
if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
|
||||
$writable = true;
|
||||
else
|
||||
|
@ -88,7 +86,7 @@ if ($wp_rewrite->using_index_permalinks())
|
|||
else
|
||||
$usingpi = false;
|
||||
|
||||
save_mod_rewrite_rules();
|
||||
$wp_rewrite->flush_rules();
|
||||
?>
|
||||
|
||||
<?php if (isset($_POST['submit'])) : ?>
|
||||
|
|
|
@ -66,7 +66,7 @@ case 'update':
|
|||
// If siteurl or home changed, reset cookies.
|
||||
if ( get_settings('siteurl') != $old_siteurl || get_settings('home') != $old_home ) {
|
||||
// If home changed, write rewrite rules to new location.
|
||||
save_mod_rewrite_rules();
|
||||
$wp_rewrite->flush_rules();
|
||||
// Get currently logged in user and password.
|
||||
get_currentuserinfo();
|
||||
// Clear cookies for old paths.
|
||||
|
|
|
@ -4,7 +4,7 @@ require_once(ABSPATH . '/wp-admin/admin-functions.php');
|
|||
require_once(ABSPATH . '/wp-admin/upgrade-schema.php');
|
||||
// Functions to be called in install and upgrade scripts
|
||||
function upgrade_all() {
|
||||
global $wp_current_db_version, $wp_db_version;
|
||||
global $wp_current_db_version, $wp_db_version, $wp_rewrite;
|
||||
$wp_current_db_version = __get_option('db_version');
|
||||
|
||||
// We are up-to-date. Nothing to do.
|
||||
|
@ -33,8 +33,7 @@ function upgrade_all() {
|
|||
if ( $wp_current_db_version < 3308 )
|
||||
upgrade_160();
|
||||
|
||||
generate_page_rewrite_rules();
|
||||
save_mod_rewrite_rules();
|
||||
$wp_rewrite->flush_rules();
|
||||
|
||||
update_option('db_version', $wp_db_version);
|
||||
}
|
||||
|
|
|
@ -1339,8 +1339,14 @@ class WP_Rewrite {
|
|||
}
|
||||
|
||||
function wp_rewrite_rules() {
|
||||
$this->matches = 'matches';
|
||||
return $this->rewrite_rules();
|
||||
$this->rules = get_option('rewrite_rules');
|
||||
if ( empty($this->rules) ) {
|
||||
$this->matches = 'matches';
|
||||
$this->rewrite_rules();
|
||||
update_option('rewrite_rules', $this->rules);
|
||||
}
|
||||
|
||||
return $this->rules;
|
||||
}
|
||||
|
||||
function mod_rewrite_rules() {
|
||||
|
@ -1396,6 +1402,14 @@ class WP_Rewrite {
|
|||
return $rules;
|
||||
}
|
||||
|
||||
function flush_rules() {
|
||||
generate_page_rewrite_rules();
|
||||
delete_option('rewrite_rules');
|
||||
$this->wp_rewrite_rules();
|
||||
if ( function_exists('save_mod_rewrite_rules') )
|
||||
save_mod_rewrite_rules();
|
||||
}
|
||||
|
||||
function init() {
|
||||
$this->permalink_structure = get_settings('permalink_structure');
|
||||
$this->front = substr($this->permalink_structure, 0, strpos($this->permalink_structure, '%'));
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* generic function for inserting data into the posts table.
|
||||
*/
|
||||
function wp_insert_post($postarr = array()) {
|
||||
global $wpdb, $allowedtags, $user_ID;
|
||||
global $wpdb, $wp_rewrite, $allowedtags, $user_ID;
|
||||
|
||||
if ( is_object($postarr) )
|
||||
$postarr = get_object_vars($postarr);
|
||||
|
@ -196,7 +196,7 @@ function wp_insert_post($postarr = array()) {
|
|||
spawn_pinger();
|
||||
}
|
||||
} else if ($post_status == 'static') {
|
||||
generate_page_rewrite_rules();
|
||||
$wp_rewrite->flush_rules();
|
||||
|
||||
if ( !empty($page_template) )
|
||||
if ( ! update_post_meta($post_ID, '_wp_page_template', $page_template))
|
||||
|
@ -526,7 +526,7 @@ function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array(
|
|||
} // wp_set_post_cats()
|
||||
|
||||
function wp_delete_post($postid = 0) {
|
||||
global $wpdb;
|
||||
global $wpdb, $wp_rewrite;
|
||||
$postid = (int) $postid;
|
||||
|
||||
if ( !$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $postid") )
|
||||
|
@ -559,8 +559,8 @@ function wp_delete_post($postid = 0) {
|
|||
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = $postid");
|
||||
|
||||
if ( 'static' == $post->post_status )
|
||||
generate_page_rewrite_rules();
|
||||
|
||||
$wp_rewrite->flush_rules();
|
||||
|
||||
return $post;
|
||||
}
|
||||
|
||||
|
@ -818,8 +818,6 @@ function generate_page_rewrite_rules() {
|
|||
|
||||
if ( $page_attachment_rewrite_rules )
|
||||
update_option('page_attachment_uris', $page_attachment_rewrite_rules);
|
||||
|
||||
save_mod_rewrite_rules();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue