[wp-trac] [WordPress Trac] #29107: WP_Rewrite::flush_rules() should not delete 'rewrite_rules' option

WordPress Trac noreply at wordpress.org
Mon Aug 4 11:50:52 UTC 2014


#29107: WP_Rewrite::flush_rules() should not delete 'rewrite_rules' option
----------------------------+-----------------------------
 Reporter:  SergeyBiryukov  |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Rewrite Rules   |    Version:  2.0.1
 Severity:  normal          |   Keywords:  has-patch
  Focuses:                  |
----------------------------+-----------------------------
 If permalinks are disabled, there's an extra query on each page load:
 {{{
 SELECT option_value FROM trunk_options WHERE option_name = 'rewrite_rules'
 LIMIT 1
 }}}

 It comes from [source:tags/3.9.1/src/wp-includes/class-wp.php#L110
 WP::parse_request()], which calls [source:tags/3.9.1/src/wp-
 includes/rewrite.php#L1733 WP_Rewrite::wp_rewrite_rules()].

 Normally, it should be covered by [source:tags/3.9.1/src/wp-
 includes/option.php#L153 wp_load_alloptions()], but:

 1. The `rewrite_rules` option is not created on installation.
 2. If you enable permalinks and disable them again, [source:tags/3.9.1/src
 /wp-includes/rewrite.php#L2034 WP_Rewrite::flush_rules()] deletes the
 option.
 3. [source:tags/3.9.1/src/wp-includes/rewrite.php#L1733
 WP_Rewrite::wp_rewrite_rules()] attempts to recreate it, but fails due to
 the [source:/tags/3.9.1/src/wp-includes/option.php#L269 check in
 update_option()].

 I think we should replace `rewrite_rules` option with an empty value
 instead of deleting it.

 Introduced in [3373].

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29107>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list