Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
BufferHandler
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 handle
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2/**
3 * @license GPL-2.0-or-later
4 * @file
5 */
6
7namespace MediaWiki\Logger\Monolog;
8
9use MediaWiki\Deferred\DeferredUpdates;
10use Monolog\Handler\BufferHandler as BaseBufferHandler;
11use Monolog\LogRecord;
12
13/**
14 * Helper class for the index.php entry point.
15 *
16 * Updates \Monolog\Handler\BufferHandler to use DeferredUpdates rather
17 * than register_shutdown_function. On supported platforms this will
18 * use register_postsend_function or fastcgi_finish_request() to delay
19 * until after the request has shutdown and we are no longer delaying
20 * the web request.
21 *
22 * TODO: shutdown is later than postsend. Is this class still useful?
23 *
24 * @since 1.26
25 * @ingroup Debug
26 */
27class BufferHandler extends BaseBufferHandler {
28    /**
29     * @inheritDoc
30     */
31    public function handle( LogRecord $record ): bool {
32        if ( !$this->initialized ) {
33            DeferredUpdates::addCallableUpdate( $this->close( ... ) );
34            $this->initialized = true;
35        }
36        return parent::handle( $record );
37    }
38}