[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 Oct 1 07:45:37 UTC 2015


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

Comment (by dd32):

 In [changeset:"34740"]:
 {{{
 #!CommitTicketReference repository="" revision="34740"
 Rewrite `insert_with_markers()` to use `flock()` when available,
 significant cleanup of the function too.

 The call to `flock()` is an exclusive advisory lock, which in my testing
 only PHP respects (apache continues to read it).
 Not all filesystems support locking (remote NFS mounts for example) so
 this offers minimal benefit to those platforms, but offers much better
 protection against file corruption on systems which do support it.
 The call is blocking, so a second process will wait for the first to
 complete before writing if supported.

 See #31767
 }}}

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


More information about the wp-trac mailing list