Skip to content

Commit

Permalink
Request: $query is deprecated, parameters are taken form $url (BC break)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Dec 27, 2014
1 parent 856330f commit ca5f760
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
16 changes: 6 additions & 10 deletions src/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ class Request extends Nette\Object implements IRequest
/** @var UrlScript */
private $url;

/** @var array */
private $query;

/** @var array */
private $post;

Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/Http/RequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public function createHttpRequest()
}
unset($list, $key, $val, $k, $v);
}
$url->setQuery($query);


// FILES and create FileUpload objects
Expand Down Expand Up @@ -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);
}

}

0 comments on commit ca5f760

Please sign in to comment.