[wp-trac] [WordPress Trac] #31767: insert_with_markers() is not atomic, leading to corrupted .htaccess updates under race conditions

WordPress Trac noreply at wordpress.org
Thu Jul 30 18:26:08 UTC 2015


#31767: insert_with_markers() is not atomic, leading to corrupted .htaccess updates
under race conditions
----------------------------+------------------------------
 Reporter:  tigertech       |       Owner:
     Type:  defect (bug)    |      Status:  new
 Priority:  normal          |   Milestone:  Awaiting Review
Component:  Filesystem API  |     Version:  4.1.1
 Severity:  critical        |  Resolution:
 Keywords:  has-patch       |     Focuses:
----------------------------+------------------------------

Comment (by kevinatelement):

 I can confirm that this is a serious issue that manifests in production
 environments.

 We ran into it a couple times over a 18 month period, before digging in
 deep to determine the cause.

 We have a workaround in place which disables WordPress from updating the
 .htaccess entirely, but it's a pretty ugly workaround due to the fact that
 the only hook available is got_mod_rewrite and to always return false
 there would affect permalink structures.  So we need to peek into the call
 stack to decide what the context of the call to got_mod_rewrite was so we
 can prevent insert_with_markers.

 In case anyone else is interested in this workaround, here it is:

 {{{
 add_filter('got_rewrite', 'turn_off_rewrite');
 function turn_off_rewrite() {
         $backtrace = debug_backtrace();
         foreach($backtrace as $trace) {
                 if(isset($trace['function']) && $trace['function'] ==
 'save_mod_rewrite_rules') {
                         return false;
                 }
         }
         return true;
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/31767#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list