[wp-trac] [WordPress Trac] #32471: There is no proper way to flush rewrite rules at plugin network de-activation

WordPress Trac noreply at wordpress.org
Sat May 23 10:28:04 UTC 2015


#32471: There is no proper way to flush rewrite rules at plugin network de-
activation
---------------------------+-----------------------------
 Reporter:  Chouby         |      Owner:
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Rewrite Rules  |    Version:  3.0
 Severity:  normal         |   Keywords:
  Focuses:  multisite      |
---------------------------+-----------------------------
 It is considered as best practice for a plugin modifying rewrite rules to
 flush them at activation and de-activation:
 http://codex.wordpress.org/Function_Reference/flush_rewrite_rules

 Plugins should then handle this at network activation and de-activation
 too. Following a [https://core.trac.wordpress.org/ticket/14170#comment:30
 comment] from @nacin on #14170, we can find a way to handle this properly
 at network activation. We can even make something which scales using for
 example the plugin [https://wordpress.org/plugins/proper-network-
 activation/ proper network activation] from @scribu as a basis.

 However the only proposal I found to handle the network de-activation is:

 {{{
 foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs") as $blog_id) {
         switch_to_blog($blog_id);
         flush_rewrite_rules();
         restore_current_blog();
 }
 }}}
 Apart from the fact that it does not scale, it would mess the rewrite
 rules of all blogs. I am aware of #20171 but fixing it with the proposed
 patch is not sufficient as other plugins may modify the rewrite rules and
 we then face the fact that $wp_rewrite->extra_rules_top is shared accross
 blogs.

 So the only way I foresee as a potential solution is that the network de-
 activation is not handled at network level but that each blog runs its own
 individual de-activation process - in a similar way as @nacin proposed for
 the activation as indeed, with the current architecture, we must never mix
 switch_to_blog() and flush_rewrite_rules().

 Unless I miss something, it seems that there is currently no way for a
 plugin to properly flush rewrite rules at network de-activation.

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


More information about the wp-trac mailing list