Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions classes/Kohana/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -667,13 +667,9 @@ public function __construct($uri, $client_params = array(), $allow_external = TR
$split_uri = explode('?', $uri);
$uri = array_shift($split_uri);

// Initial request has global $_GET already applied
if (Request::$initial === NULL)
if ($split_uri)
{
if ($split_uri)
{
parse_str($split_uri[0], $this->_get);
}
parse_str($split_uri[0], $this->_get);
}

// Detect protocol (if present)
Expand Down
38 changes: 33 additions & 5 deletions tests/kohana/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ public function provider_query_parameter_parsing()
{
return array(
array(
new Request('foo/bar'),
'foo/bar',
array(
'foo' => 'bar',
'sna' => 'fu'
Expand All @@ -631,7 +631,7 @@ public function provider_query_parameter_parsing()
),
),
array(
new Request('foo/bar?john=wayne&peggy=sue'),
'foo/bar?john=wayne&peggy=sue',
array(
'foo' => 'bar',
'sna' => 'fu'
Expand All @@ -644,7 +644,7 @@ public function provider_query_parameter_parsing()
),
),
array(
new Request('http://host.tld/foo/bar?john=wayne&peggy=sue'),
'http://host.tld/foo/bar?john=wayne&peggy=sue',
array(
'foo' => 'bar',
'sna' => 'fu'
Expand All @@ -664,13 +664,41 @@ public function provider_query_parameter_parsing()
*
* @dataProvider provider_query_parameter_parsing
*
* @param Request request
* @param string url
* @param array query
* @param array expected
* @return void
*/
public function test_query_parameter_parsing(Request $request, $query, $expected)
public function test_query_parameter_parsing($url, $query, $expected)
{
Request::$initial = NULL;

$request = new Request($url);

foreach ($query as $key => $value)
{
$request->query($key, $value);
}

$this->assertSame($expected, $request->query());
}

/**
* Tests that query parameters are parsed correctly
*
* @dataProvider provider_query_parameter_parsing
*
* @param string url
* @param array query
* @param array expected
* @return void
*/
public function test_query_parameter_parsing_in_subrequest($url, $query, $expected)
{
Request::$initial = new Request(TRUE);

$request = new Request($url);

foreach ($query as $key => $value)
{
$request->query($key, $value);
Expand Down