X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FWebResponse.php;h=0208a72ab962717091f1870193fbe9f7fa1c1248;hb=9604c55869b0879f944215eda992570820b55ec8;hp=c7d0a5bea884242a97284f839cda3ce82b6fd843;hpb=40a628a501fc05bb00e834fe359ca4061925f320;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/WebResponse.php b/includes/WebResponse.php index c7d0a5bea8..0208a72ab9 100644 --- a/includes/WebResponse.php +++ b/includes/WebResponse.php @@ -39,7 +39,12 @@ class WebResponse { * @param null|int $http_response_code Forces the HTTP response code to the specified value. */ public function header( $string, $replace = true, $http_response_code = null ) { - header( $string, $replace, $http_response_code ); + \MediaWiki\HeaderCallback::warnIfHeadersSent(); + if ( $http_response_code ) { + header( $string, $replace, $http_response_code ); + } else { + header( $string, $replace ); + } } /** @@ -89,26 +94,12 @@ class WebResponse { * path: string, cookie path ($wgCookiePath) * secure: bool, secure attribute ($wgCookieSecure) * httpOnly: bool, httpOnly attribute ($wgCookieHttpOnly) - * raw: bool, if true uses PHP's setrawcookie() instead of setcookie() - * For backwards compatibility, if $options is not an array then it and - * the following two parameters will be interpreted as values for - * 'prefix', 'domain', and 'secure' * @since 1.22 Replaced $prefix, $domain, and $forceSecure with $options */ public function setCookie( $name, $value, $expire = 0, $options = [] ) { global $wgCookiePath, $wgCookiePrefix, $wgCookieDomain; global $wgCookieSecure, $wgCookieExpiration, $wgCookieHttpOnly; - if ( !is_array( $options ) ) { - // Backwards compatibility - $options = [ 'prefix' => $options ]; - if ( func_num_args() >= 5 ) { - $options['domain'] = func_get_arg( 4 ); - } - if ( func_num_args() >= 6 ) { - $options['secure'] = func_get_arg( 5 ); - } - } $options = array_filter( $options, function ( $a ) { return $a !== null; } ) + [ @@ -179,6 +170,16 @@ class WebResponse { public function clearCookie( $name, $options = [] ) { $this->setCookie( $name, '', time() - 31536000 /* 1 year */, $options ); } + + /** + * Checks whether this request is performing cookie operations + * + * @return bool + * @since 1.27 + */ + public function hasCookies() { + return (bool)self::$setCookies; + } } /** @@ -258,16 +259,6 @@ class FauxResponse extends WebResponse { global $wgCookiePath, $wgCookiePrefix, $wgCookieDomain; global $wgCookieSecure, $wgCookieExpiration, $wgCookieHttpOnly; - if ( !is_array( $options ) ) { - // Backwards compatibility - $options = [ 'prefix' => $options ]; - if ( func_num_args() >= 5 ) { - $options['domain'] = func_get_arg( 4 ); - } - if ( func_num_args() >= 6 ) { - $options['secure'] = func_get_arg( 5 ); - } - } $options = array_filter( $options, function ( $a ) { return $a !== null; } ) + [