warning( 'Cookies set on {url} with Cache-Control "{cache-control}"', [ 'url' => \WebRequest::getGlobalRequestURL(), 'cookies' => $headers['set-cookie'], 'cache-control' => $cacheControl ?: '', ] ); } } // Save a backtrace for logging in case it turns out that headers were sent prematurely self::$headersSentException = new \Exception( 'Headers already sent from this point' ); } /** * Log a warning message if headers have already been sent. This can be * called before flushing the output. */ public static function warnIfHeadersSent() { if ( headers_sent() && !self::$messageSent ) { self::$messageSent = true; \MWDebug::warning( 'Headers already sent, should send headers earlier than ' . wfGetCaller( 3 ) ); $logger = \MediaWiki\Logger\LoggerFactory::getInstance( 'headers-sent' ); $logger->error( 'Warning: headers were already sent from the location below', [ 'exception' => self::$headersSentException, 'detection-trace' => new \Exception( 'Detected here' ), ] ); } } }