diff --git a/wp-admin/admin.php b/wp-admin/admin.php index 2c216386dd..f8405f9a09 100644 --- a/wp-admin/admin.php +++ b/wp-admin/admin.php @@ -146,7 +146,7 @@ if (isset($plugin_page)) { // Make sure rules are flushed global $wp_rewrite; - $wp_rewrite->flush_rules(); + $wp_rewrite->flush_rules(false); exit(); } else { diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index d020e74add..b717f65a52 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -72,7 +72,9 @@ function insert_with_markers( $filename, $marker, $insertion ) { $markerdata = explode( "\n", implode( '', file( $filename ) ) ); } - $f = fopen( $filename, 'w' ); + if ( !$f = @fopen( $filename, 'w' ) ) + return false; + $foundit = false; if ( $markerdata ) { $state = true; diff --git a/wp-includes/post.php b/wp-includes/post.php index 407b33c576..0c0ba46d6d 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -1192,7 +1192,7 @@ function wp_delete_post($postid = 0) { foreach ( (array) $children as $child ) clean_page_cache($child->ID); - $wp_rewrite->flush_rules(); + $wp_rewrite->flush_rules(false); } else { clean_post_cache($postid); } @@ -3354,7 +3354,7 @@ function _save_post_hook($post_id, $post) { // Avoid flushing rules for every post during import. if ( !defined('WP_IMPORTING') ) { global $wp_rewrite; - $wp_rewrite->flush_rules(); + $wp_rewrite->flush_rules(false); } } else { clean_post_cache($post_id); diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index c84b5205ed..3486c4a5b4 100644 --- a/wp-includes/rewrite.php +++ b/wp-includes/rewrite.php @@ -1822,13 +1822,14 @@ class WP_Rewrite { * * @since 2.0.1 * @access public + * @param $hard bool Whether to update .htaccess (hard flush) or just update rewrite_rules transient (soft flush). Default is true (hard). */ - function flush_rules() { + function flush_rules($hard = true) { delete_transient('rewrite_rules'); $this->wp_rewrite_rules(); - if ( function_exists('save_mod_rewrite_rules') ) + if ( $hard && function_exists('save_mod_rewrite_rules') ) save_mod_rewrite_rules(); - if ( function_exists('iis7_save_url_rewrite_rules') ) + if ( $hard && function_exists('iis7_save_url_rewrite_rules') ) iis7_save_url_rewrite_rules(); }