From 94992e25ae6f94b5cdf9e8c51daeddfdf54453a5 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Sun, 10 Jan 2016 19:01:13 +0000 Subject: [PATCH] Rewrite: Ensure `WP_Rewrite::flush_rules()` does not delete the 'rewrite_rules' option. Instead, the option gets updated to an empty string. Adds unit tests. Props SergeyBiryukov, jesin, voldemortensen. Fixes #29107. git-svn-id: https://develop.svn.wordpress.org/trunk@36254 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/rewrite.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/phpunit/tests/rewrite.php b/tests/phpunit/tests/rewrite.php index 1f7426e3d3..5db9eddc18 100644 --- a/tests/phpunit/tests/rewrite.php +++ b/tests/phpunit/tests/rewrite.php @@ -320,4 +320,19 @@ class Tests_Rewrite extends WP_UnitTestCase { $this->set_permalink_structure(); } + /** + * @ticket 29107 + */ + public function test_flush_rules_does_not_delete_option() { + $this->set_permalink_structure(); + + $rewrite_rules = get_option( 'rewrite_rules' ); + $this->assertSame( '', $rewrite_rules ); + + $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); + + $rewrite_rules = get_option( 'rewrite_rules' ); + $this->assertInternalType( 'array', $rewrite_rules ); + $this->assertNotEmpty( $rewrite_rules ); + } }