X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FWebResponse.php;h=1b6947cd961c4a09177f1fb0e7d62e13515d7956;hp=d39f884789e550a8bebffe3ea24785e41aa7d69d;hb=b51076a84446d157bed511246450e70d26e0f945;hpb=30e009794bacc2e3138c372e6ddf876dca2d4a9c diff --git a/includes/WebResponse.php b/includes/WebResponse.php index d39f884789..1b6947cd96 100644 --- a/includes/WebResponse.php +++ b/includes/WebResponse.php @@ -28,7 +28,7 @@ class WebResponse { /** - * Output a HTTP header, wrapper for PHP's header() + * Output an HTTP header, wrapper for PHP's header() * @param string $string Header to output * @param bool $replace Replace current similar header * @param null|int $http_response_code Forces the HTTP response code to the specified value. @@ -53,10 +53,19 @@ class WebResponse { return null; } + /** + * Output an HTTP status code header + * @since 1.26 + * @param int $code Status code + */ + public function statusHeader( $code ) { + HttpStatus::header( $code ); + } + /** * Set the browser cookie - * @param string $name Name of cookie - * @param string $value Value to give cookie + * @param string $name The name of the cookie. + * @param string $value The value to be stored in the cookie. * @param int|null $expire Unix timestamp (in seconds) when the cookie should expire. * 0 (the default) causes it to expire $wgCookieExpiration seconds from now. * null causes it to be a session cookie. @@ -72,7 +81,7 @@ class WebResponse { * 'prefix', 'domain', and 'secure' * @since 1.22 Replaced $prefix, $domain, and $forceSecure with $options */ - public function setcookie( $name, $value, $expire = 0, $options = null ) { + public function setcookie( $name, $value, $expire = 0, $options = array() ) { global $wgCookiePath, $wgCookiePrefix, $wgCookieDomain; global $wgCookieSecure, $wgCookieExpiration, $wgCookieHttpOnly; @@ -105,7 +114,7 @@ class WebResponse { $func = $options['raw'] ? 'setrawcookie' : 'setcookie'; - if ( wfRunHooks( 'WebResponseSetCookie', array( &$name, &$value, &$expire, $options ) ) ) { + if ( Hooks::run( 'WebResponseSetCookie', array( &$name, &$value, &$expire, $options ) ) ) { wfDebugLog( 'cookie', $func . ': "' . implode( '", "', array( @@ -162,9 +171,17 @@ class FauxResponse extends WebResponse { } } + /** + * @since 1.26 + * @param int $code Status code + */ + public function statusHeader( $code ) { + $this->code = intval( $code ); + } + /** * @param string $key The name of the header to get (case insensitive). - * @return string + * @return string|null The header value (if set); null otherwise. */ public function getHeader( $key ) { $key = strtoupper( $key ); @@ -185,20 +202,18 @@ class FauxResponse extends WebResponse { } /** - * @todo document. It just ignore optional parameters. - * - * @param string $name Name of cookie - * @param string $value Value to give cookie - * @param int $expire Number of seconds til cookie expires (Default: 0) - * @param array $options Ignored + * @param string $name The name of the cookie. + * @param string $value The value to be stored in the cookie. + * @param int|null $expire Ignored in this faux subclass. + * @param array $options Ignored in this faux subclass. */ - public function setcookie( $name, $value, $expire = 0, $options = null ) { + public function setcookie( $name, $value, $expire = 0, $options = array() ) { $this->cookies[$name] = $value; } /** * @param string $name - * @return string + * @return string|null */ public function getcookie( $name ) { if ( isset( $this->cookies[$name] ) ) {