[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
Fri Oct 2 17:29:13 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 tigertech):
I've tested this, and the good news is that the patch appears to solve the
corruption problem in the vast majority of cases.
On systems that support `flock()`, it should completely solve it; on
systems that don't, the code cleanup of "writing everything all at once"
will make it much less likely to happen (the new code is also noticeably
far faster when calling `insert_with_markers` thousands of times in a
test, reducing the amount of time a race condition could exist).
However, as @willmot noticed, it has a new bug: it doesn't create a
missing file any more, and it needs to. Perhaps the fix for could be as
simple as adding this at the top of the function:
{{{
if (!file_exists( $filename ) ) {
if(!touch( $filename )) {
return false;
}
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/31767#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list