Don't write to htaccess every time page is saved. Add hard/soft flush flag to flush_rules(). Make sure fopen is successful and silence errors. Props Viper007Bond. fixes #10181 for trunk
git-svn-id: http://svn.automattic.com/wordpress/trunk@11578 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
fe813ce063
commit
4d0c574bed
|
@ -146,7 +146,7 @@ if (isset($plugin_page)) {
|
||||||
|
|
||||||
// Make sure rules are flushed
|
// Make sure rules are flushed
|
||||||
global $wp_rewrite;
|
global $wp_rewrite;
|
||||||
$wp_rewrite->flush_rules();
|
$wp_rewrite->flush_rules(false);
|
||||||
|
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -72,7 +72,9 @@ function insert_with_markers( $filename, $marker, $insertion ) {
|
||||||
$markerdata = explode( "\n", implode( '', file( $filename ) ) );
|
$markerdata = explode( "\n", implode( '', file( $filename ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$f = fopen( $filename, 'w' );
|
if ( !$f = @fopen( $filename, 'w' ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
$foundit = false;
|
$foundit = false;
|
||||||
if ( $markerdata ) {
|
if ( $markerdata ) {
|
||||||
$state = true;
|
$state = true;
|
||||||
|
|
|
@ -1192,7 +1192,7 @@ function wp_delete_post($postid = 0) {
|
||||||
foreach ( (array) $children as $child )
|
foreach ( (array) $children as $child )
|
||||||
clean_page_cache($child->ID);
|
clean_page_cache($child->ID);
|
||||||
|
|
||||||
$wp_rewrite->flush_rules();
|
$wp_rewrite->flush_rules(false);
|
||||||
} else {
|
} else {
|
||||||
clean_post_cache($postid);
|
clean_post_cache($postid);
|
||||||
}
|
}
|
||||||
|
@ -3354,7 +3354,7 @@ function _save_post_hook($post_id, $post) {
|
||||||
// Avoid flushing rules for every post during import.
|
// Avoid flushing rules for every post during import.
|
||||||
if ( !defined('WP_IMPORTING') ) {
|
if ( !defined('WP_IMPORTING') ) {
|
||||||
global $wp_rewrite;
|
global $wp_rewrite;
|
||||||
$wp_rewrite->flush_rules();
|
$wp_rewrite->flush_rules(false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
clean_post_cache($post_id);
|
clean_post_cache($post_id);
|
||||||
|
|
|
@ -1822,13 +1822,14 @@ class WP_Rewrite {
|
||||||
*
|
*
|
||||||
* @since 2.0.1
|
* @since 2.0.1
|
||||||
* @access public
|
* @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');
|
delete_transient('rewrite_rules');
|
||||||
$this->wp_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();
|
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();
|
iis7_save_url_rewrite_rules();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue