From 66e483d3e74e1179455e8cde830ac819f38dd99b Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 1 Apr 2015 19:06:29 +0000 Subject: [PATCH] When shifting `WP_Rewrite::flush_rules()` to a later action if it was called too early, make sure to do a hard flush if requested. props Denis-de-Bernardy, mordauk for initial patch. fixes #30501. Built from https://develop.svn.wordpress.org/trunk@31964 git-svn-id: http://core.svn.wordpress.org/trunk@31943 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/rewrite.php | 10 +++++++++- wp-includes/version.php | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index 252922851e..45d28cea97 100644 --- a/wp-includes/rewrite.php +++ b/wp-includes/rewrite.php @@ -2044,13 +2044,21 @@ class WP_Rewrite { * @access public * @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard). */ - public function flush_rules($hard = true) { + public function flush_rules( $hard = true ) { + static $do_hard_later; + // Prevent this action from running before everyone has registered their rewrites if ( ! did_action( 'wp_loaded' ) ) { add_action( 'wp_loaded', array( $this, 'flush_rules' ) ); + $do_hard_later = ( isset( $do_hard_later ) ) ? $do_hard_later || $hard : $hard; return; } + if ( isset( $do_hard_later ) ) { + $hard = $do_hard_later; + unset( $do_hard_later ); + } + delete_option('rewrite_rules'); $this->wp_rewrite_rules(); /** diff --git a/wp-includes/version.php b/wp-includes/version.php index e72f3ef6f6..f071f82786 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.2-beta3-31963'; +$wp_version = '4.2-beta3-31964'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.