Index: wp-includes/rewrite.php
===================================================================
--- wp-includes/rewrite.php	(revision 30562)
+++ wp-includes/rewrite.php	(working copy)
@@ -2041,6 +2041,12 @@
 	 * @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) {
+		// Prevent this action from running before everyone has registered their rewrites
+		if ( ! did_action( 'init' ) ) {
+			add_action( 'init', array( $this, 'flush_rules' ) );
+			return;
+		}
+
 		delete_option('rewrite_rules');
 		$this->wp_rewrite_rules();
 		/**
