Index: src/wp-includes/rewrite.php
===================================================================
--- src/wp-includes/rewrite.php	(revision 31834)
+++ src/wp-includes/rewrite.php	(working copy)
@@ -2045,10 +2045,22 @@
 	 * @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) {
+		
+		static $do_hard_later;
+
 		// Prevent this action from running before everyone has registered their rewrites
-		if ( ! did_action( 'wp_loaded' ) ) {
+		if ( ! did_action( 'wp_loaded' ) ) { 
+
 			add_action( 'wp_loaded', array( $this, 'flush_rules' ) );
-			return;
+			$do_hard_later = $hard;
+
+			return; 
+
+		} elseif ( isset( $do_hard_later ) && doing_action( 'wp_loaded' ) ) {
+
+			$hard = $do_hard_later;
+			$do_hard_later = null;
+
 		}
 
 		delete_option('rewrite_rules');
