From: Zhuyifei1999 Date: Wed, 9 Aug 2017 09:51:41 +0000 (+0000) Subject: FileRepo: create output buffer and set ob_implicit_flush for file streaming X-Git-Tag: 1.31.0-rc.0~2436^2 X-Git-Url: http://git.cyclocoop.org/%22.%24image2.%22?a=commitdiff_plain;h=0bce3d6b8c1dc3c2aa1e686f0b5bafc4fd9ba550;p=lhc%2Fweb%2Fwiklou.git FileRepo: create output buffer and set ob_implicit_flush for file streaming HHVM does not flush automatically until the output is done, unless flush() is called. We create an output buffer so that PHP is aware of the amount of data in the output buffer; we set ob_implicit_flush so that, when output buffer is full and being flushed, it flushes HHVM's buffer as well, emptying the OOM culprit. Bug: T172851 Change-Id: I34dd1034590779ab51f197762177ad03291e3581 --- diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index f89d96b218..dc36e50a1e 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -1602,9 +1602,15 @@ class FileRepo { $path = $this->resolveToStoragePath( $virtualUrl ); $params = [ 'src' => $path, 'headers' => $headers, 'options' => $optHeaders ]; + // T172851: HHVM does not flush the output properly, causing OOM + ob_start( NULL, 1048576 ); + ob_implicit_flush( true ); + $status = $this->newGood(); $status->merge( $this->backend->streamFile( $params ) ); + ob_end_flush(); + return $status; }