[wp-trac] [WordPress Trac] #14730: ms-files.php required ob_clean() and flush()

WordPress Trac noreply at wordpress.org
Tue Sep 27 20:00:41 UTC 2016


#14730: ms-files.php required ob_clean() and flush()
--------------------------+-------------------------
 Reporter:  pj_mfc        |       Owner:  jeremyfelt
     Type:  defect (bug)  |      Status:  reviewing
 Priority:  normal        |   Milestone:  4.7
Component:  Multisite     |     Version:  4.2.2
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:  multisite
--------------------------+-------------------------

Comment (by jeremyfelt):

 I'm going to go ahead and commit part of the original patch and place a
 `flush()` after `readfile()`. Based on @iamfriendly and my testing, I
 don't believe this will cause any issues. Based on the extensive testing
 in [https://core.trac.wordpress.org/ticket/14730#comment:2 from several
 years ago], it seems like this is the right approach for something that
 appears to be incredibly hard to reproduce. :)

 Notes on approaches:
 * The replacement `readfile()` function no longer exists at php.net, but
 can be found around the web as `readfile_chunked()` (not sure what its
 licensing is). It uses `fopen()`, `fgets()`, `fread()`, etc... to chunk
 through a larger file.
 * I can't make sense of adding `ob_clean()` and `flush()` before
 `readfile()`. There are no themes or plugins in play here, and only
 headers have been built by `ms-files.php` when `readfile()` is called.
 It's very possible I'm missing something, but I'd rather not add more than
 we need.
 * Looking at the source of `readfile()`, it (via `php_stream_passthru`)
 ''outputs all remaining data from stream to the active output buffer and
 returns the number of bytes output. If buffering is disabled, the data is
 written straight to the output''. It seems harmless to then use `flush()`
 after to ensure all of the output has been pushed.

 I'm still not confident in the "why", but this should resolve the issue.
 We can readdress if it continues to appear.

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


More information about the wp-trac mailing list