From d6d5cc2e0ff1b928ee2cc6cf2127525a59c0eebc Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sat, 27 Dec 2014 01:48:12 +0100 Subject: [PATCH] Request: $query is deprecated, parameters are taken form $url (BC break) --- src/Http/Request.php | 16 ++++++---------- src/Http/RequestFactory.php | 3 ++- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Http/Request.php b/src/Http/Request.php index cb30cee7..99bd00b5 100644 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -37,9 +37,6 @@ class Request extends Nette\Object implements IRequest /** @var UrlScript */ private $url; - /** @var array */ - private $query; - /** @var array */ private $post; @@ -66,7 +63,10 @@ public function __construct(UrlScript $url, $query = NULL, $post = NULL, $files $headers = NULL, $method = NULL, $remoteAddress = NULL, $remoteHost = NULL, $rawBodyCallback = NULL) { $this->url = $url; - $this->query = $query === NULL ? $url->getQueryParameters() : (array) $query; + if ($query !== NULL) { + trigger_error('Nette\Http\Request::__construct(): parameter $query is deprecated.', E_USER_DEPRECATED); + $url->setQuery($query); + } $this->post = (array) $post; $this->files = (array) $files; $this->cookies = (array) $cookies; @@ -101,13 +101,9 @@ public function getUrl() public function getQuery($key = NULL, $default = NULL) { if (func_num_args() === 0) { - return $this->query; - - } elseif (isset($this->query[$key])) { - return $this->query[$key]; - + return $this->url->getQueryParameters(); } else { - return $default; + return $this->url->getQueryParameter($key, $default); } } diff --git a/src/Http/RequestFactory.php b/src/Http/RequestFactory.php index 54525f4f..21678306 100644 --- a/src/Http/RequestFactory.php +++ b/src/Http/RequestFactory.php @@ -137,6 +137,7 @@ public function createHttpRequest() } unset($list, $key, $val, $k, $v); } + $url->setQuery($query); // FILES and create FileUpload objects @@ -239,7 +240,7 @@ public function createHttpRequest() return $rawBody; }; - return new Request($url, $query, $post, $files, $cookies, $headers, $method, $remoteAddr, $remoteHost, $rawBodyCallback); + return new Request($url, NULL, $post, $files, $cookies, $headers, $method, $remoteAddr, $remoteHost, $rawBodyCallback); } }