X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flibs%2Ffilebackend%2FFileBackend.php;h=15f13b9b89bda217b40d7e0cd4796950c5e5dceb;hb=5111bd2def4e63ecc8a2acbf468e5c39029f9efd;hp=aa25f4343aae4f650b23eb57a9861403cab7a41d;hpb=d3f9524df3a7a0975d537b3edc4f3d0424ea675d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/filebackend/FileBackend.php b/includes/libs/filebackend/FileBackend.php index aa25f4343a..15f13b9b89 100644 --- a/includes/libs/filebackend/FileBackend.php +++ b/includes/libs/filebackend/FileBackend.php @@ -30,6 +30,7 @@ */ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; +use Wikimedia\ScopedCallback; /** * @brief Base class for all file backend classes (including multi-write backends). @@ -185,13 +186,15 @@ abstract class FileBackend implements LoggerAwareInterface { $this->concurrency = isset( $config['concurrency'] ) ? (int)$config['concurrency'] : 50; - $this->obResetFunc = isset( $params['obResetFunc'] ) ? $params['obResetFunc'] : null; - $this->streamMimeFunc = isset( $params['streamMimeFunc'] ) - ? $params['streamMimeFunc'] + $this->obResetFunc = isset( $config['obResetFunc'] ) + ? $config['obResetFunc'] + : [ $this, 'resetOutputBuffer' ]; + $this->streamMimeFunc = isset( $config['streamMimeFunc'] ) + ? $config['streamMimeFunc'] : null; $this->statusWrapper = isset( $config['statusWrapper'] ) ? $config['statusWrapper'] : null; - $this->profiler = isset( $params['profiler'] ) ? $params['profiler'] : null; + $this->profiler = isset( $config['profiler'] ) ? $config['profiler'] : null; $this->logger = isset( $config['logger'] ) ? $config['logger'] : new \Psr\Log\NullLogger(); $this->statusWrapper = isset( $config['statusWrapper'] ) ? $config['statusWrapper'] : null; $this->tmpDirectory = isset( $config['tmpDirectory'] ) ? $config['tmpDirectory'] : null; @@ -925,7 +928,7 @@ abstract class FileBackend implements LoggerAwareInterface { * @return ScopedCallback|null */ final protected function getScopedPHPBehaviorForOps() { - if ( PHP_SAPI != 'cli' ) { // http://bugs.php.net/bug.php?id=47540 + if ( PHP_SAPI != 'cli' ) { // https://bugs.php.net/bug.php?id=47540 $old = ignore_user_abort( true ); // avoid half-finished operations return new ScopedCallback( function () use ( $old ) { ignore_user_abort( $old ); @@ -1618,9 +1621,19 @@ abstract class FileBackend implements LoggerAwareInterface { protected function scopedProfileSection( $section ) { if ( $this->profiler ) { call_user_func( [ $this->profiler, 'profileIn' ], $section ); - return new ScopedCallback( [ $this->profiler, 'profileOut' ] ); + return new ScopedCallback( [ $this->profiler, 'profileOut' ], [ $section ] ); } return null; } + + protected function resetOutputBuffer() { + while ( ob_get_status() ) { + if ( !ob_end_clean() ) { + // Could not remove output buffer handler; abort now + // to avoid getting in some kind of infinite loop. + break; + } + } + } }