[wp-trac] [WordPress Trac] #37892: Make sure rewrite rules are written once 'wp_loaded' is fired

WordPress Trac noreply at wordpress.org
Wed Aug 31 09:11:27 UTC 2016


#37892: Make sure rewrite rules are written once 'wp_loaded' is fired
---------------------------+-----------------------------
 Reporter:  Chouby         |      Owner:
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Rewrite Rules  |    Version:
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 With #30501, it was made sure that an early call to
 `flush_rewrite_rules()` would not break rewrite rules.

 However, in the context of network activation / deactivation, some plugins
 don't flush the rewrite rules with `flush_rewrite_rules()` but with a
 direct call to `delete_option( 'rewrite_rules' );`. @jeremyfelt explained
 the reason for doing this in https://jeremyfelt.com/2015/07/17/flushing-
 rewrite-rules-in-wordpress-multisite-for-fun-and-profit/. For example,
 Yoast SEO and Polylang are flushing rules at activation / deactivation
 using this way.

 Now, if another plugin uses the rewrite rules before the `wp_loaded`
 action is fired (for example by calling `url_to_post_id()`, the rewrite
 rules are saved too early and are broken.

 Plugins could fix this at activation, but obviously not at deactivation.

 Inspired by what has been done to fix #30501, I propose to flush the
 rewrite rules in the 'wp_loaded' action if there is an attempt to save
 them before this action has been fired.

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


More information about the wp-trac mailing list