X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FHeaderCallback.php;h=30cc7f9fd4c4713cec8e36136d876c35eb5e7cf8;hp=b2ca6733f6cd7c1d30e780bea2145fae613f5117;hb=aeea6c552032ceb7ee3b21a17556d90bb5764cdd;hpb=55043101b2a89ea1e811b6d35e415f57ed0bf41d diff --git a/includes/HeaderCallback.php b/includes/HeaderCallback.php index b2ca6733f6..30cc7f9fd4 100644 --- a/includes/HeaderCallback.php +++ b/includes/HeaderCallback.php @@ -2,6 +2,9 @@ namespace MediaWiki; +/** + * @since 1.29 + */ class HeaderCallback { private static $headersSentException; private static $messageSent = false; @@ -10,6 +13,8 @@ class HeaderCallback { * Register a callback to be called when headers are sent. There can only * be one of these handlers active, so all relevant actions have to be in * here. + * + * @since 1.29 */ public static function register() { header_register_callback( [ __CLASS__, 'callback' ] ); @@ -17,13 +22,19 @@ class HeaderCallback { /** * The callback, which is called by the transport + * + * @since 1.29 */ public static function callback() { // Prevent caching of responses with cookies (T127993) $headers = []; foreach ( headers_list() as $header ) { - list( $name, $value ) = explode( ':', $header, 2 ); - $headers[strtolower( trim( $name ) )][] = trim( $value ); + $header = explode( ':', $header, 2 ); + + // Note: The code below (currently) does not care about value-less headers + if ( isset( $header[1] ) ) { + $headers[ strtolower( trim( $header[0] ) ) ][] = trim( $header[1] ); + } } if ( isset( $headers['set-cookie'] ) ) { @@ -53,6 +64,8 @@ class HeaderCallback { /** * Log a warning message if headers have already been sent. This can be * called before flushing the output. + * + * @since 1.29 */ public static function warnIfHeadersSent() { if ( headers_sent() && !self::$messageSent ) {