X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FWebRequest.php;h=850f10103f6e3a28caa7b16d22c74a50d8617641;hp=c99e4846db26522f44569edad536c7ac38a07cdb;hb=3a3c3e73e72f25e650480b7083b194d05d9e1bad;hpb=dae916558f37103317e1bd31b9ee7d3ca6299826 diff --git a/includes/WebRequest.php b/includes/WebRequest.php index c99e4846db..850f10103f 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -1297,6 +1297,7 @@ class FauxRequest extends WebRequest { private $wasPosted = false; private $session = array(); private $requestUrl; + protected $cookies = array(); /** * @param array $data Array of *non*-urlencoded key => value pairs, the @@ -1323,14 +1324,6 @@ class FauxRequest extends WebRequest { $this->protocol = $protocol; } - /** - * @param string $method - * @throws MWException - */ - private function notImplemented( $method ) { - throw new MWException( "{$method}() not implemented" ); - } - /** * @param string $name * @param string $default @@ -1371,7 +1364,38 @@ class FauxRequest extends WebRequest { } public function getCookie( $key, $prefix = null, $default = null ) { - return $default; + if ( $prefix === null ) { + global $wgCookiePrefix; + $prefix = $wgCookiePrefix; + } + $name = $prefix . $key; + return isset( $this->cookies[$name] ) ? $this->cookies[$name] : $default; + } + + /** + * @since 1.26 + * @param string $name Unprefixed name of the cookie to set + * @param string|null $value Value of the cookie to set + * @param string|null $prefix Cookie prefix. Defaults to $wgCookiePrefix + */ + public function setCookie( $key, $value, $prefix = null ) { + $this->setCookies( array( $key => $value ), $prefix ); + } + + /** + * @since 1.26 + * @param array $cookies + * @param string|null $prefix Cookie prefix. Defaults to $wgCookiePrefix + */ + public function setCookies( $cookies, $prefix = null ) { + if ( $prefix === null ) { + global $wgCookiePrefix; + $prefix = $wgCookiePrefix; + } + foreach ( $cookies as $key => $value ) { + $name = $prefix . $key; + $this->cookies[$name] = $value; + } } public function checkSessionCookie() { @@ -1393,17 +1417,23 @@ class FauxRequest extends WebRequest { return $this->protocol; } - private function initHeaders() { - return; - } - /** * @param string $name * @param string $val */ public function setHeader( $name, $val ) { - $name = strtoupper( $name ); - $this->headers[$name] = $val; + $this->setHeaders( array( $name => $val ) ); + } + + /** + * @since 1.26 + * @param array $headers + */ + public function setHeaders( $headers ) { + foreach ( $headers as $name => $val ) { + $name = strtoupper( $name ); + $this->headers[$name] = $val; + } } /**