Make WordPress Core

Changeset 3373


Ignore:
Timestamp:
12/28/2005 07:05:05 AM (19 years ago)
Author:
ryan
Message:

Cache rewrite rules. Add WP_Rewrite::flush_rules(). fixes #2155

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/install.php

    r3285 r3373  
    172172
    173173$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', '', '', '')");
    174 generate_page_rewrite_rules();
     174$wp_rewrite->flush_rules();
    175175
    176176// Set up admin user
  • trunk/wp-admin/options-permalink.php

    r3294 r3373  
    7777$category_base = get_settings('category_base');
    7878
    79 generate_page_rewrite_rules();
    80 
    8179if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
    8280    $writable = true;
     
    8987    $usingpi = false;
    9088
    91 save_mod_rewrite_rules();
     89$wp_rewrite->flush_rules();
    9290?>
    9391
  • trunk/wp-admin/options.php

    r3241 r3373  
    6767            if ( get_settings('siteurl') != $old_siteurl || get_settings('home') != $old_home ) {
    6868                // If home changed, write rewrite rules to new location.
    69                 save_mod_rewrite_rules();
     69                $wp_rewrite->flush_rules();
    7070                // Get currently logged in user and password.
    7171                get_currentuserinfo();
  • trunk/wp-admin/upgrade-functions.php

    r3372 r3373  
    55// Functions to be called in install and upgrade scripts
    66function upgrade_all() {
    7     global $wp_current_db_version, $wp_db_version;
     7    global $wp_current_db_version, $wp_db_version, $wp_rewrite;
    88    $wp_current_db_version = __get_option('db_version');
    99
     
    3434        upgrade_160();
    3535
    36     generate_page_rewrite_rules();
    37     save_mod_rewrite_rules();
     36    $wp_rewrite->flush_rules();
    3837   
    3938    update_option('db_version', $wp_db_version);
  • trunk/wp-includes/classes.php

    r3371 r3373  
    13401340
    13411341    function wp_rewrite_rules() {
    1342         $this->matches = 'matches';
    1343         return $this->rewrite_rules();
     1342        $this->rules = get_option('rewrite_rules');
     1343        if ( empty($this->rules) ) {
     1344            $this->matches = 'matches';
     1345            $this->rewrite_rules();
     1346            update_option('rewrite_rules', $this->rules);
     1347        }
     1348
     1349        return $this->rules;
    13441350    }
    13451351
     
    13951401
    13961402        return $rules;
     1403    }
     1404
     1405    function flush_rules() {
     1406        generate_page_rewrite_rules();
     1407        delete_option('rewrite_rules');
     1408        $this->wp_rewrite_rules();
     1409        if ( function_exists('save_mod_rewrite_rules') )
     1410            save_mod_rewrite_rules();
    13971411    }
    13981412
  • trunk/wp-includes/functions-post.php

    r3371 r3373  
    77 */
    88function wp_insert_post($postarr = array()) {
    9     global $wpdb, $allowedtags, $user_ID;
     9    global $wpdb, $wp_rewrite, $allowedtags, $user_ID;
    1010
    1111    if ( is_object($postarr) )
     
    197197        }
    198198    } else if ($post_status == 'static') {
    199         generate_page_rewrite_rules();
     199        $wp_rewrite->flush_rules();
    200200
    201201        if ( !empty($page_template) )
     
    527527
    528528function wp_delete_post($postid = 0) {
    529     global $wpdb;
     529    global $wpdb, $wp_rewrite;
    530530    $postid = (int) $postid;
    531531
     
    560560
    561561    if ( 'static' == $post->post_status )
    562         generate_page_rewrite_rules();
    563    
     562        $wp_rewrite->flush_rules();
     563
    564564    return $post;
    565565}
     
    819819        if ( $page_attachment_rewrite_rules )
    820820            update_option('page_attachment_uris', $page_attachment_rewrite_rules);
    821 
    822         save_mod_rewrite_rules();
    823821    }
    824822}
Note: See TracChangeset for help on using the changeset viewer.