Skip to content

Commit

Permalink
Merge branch '3.1/hotfix/3.1.3.1' into 3.1/master
Browse files Browse the repository at this point in the history
  • Loading branch information
zombor committed May 6, 2011
2 parents 05fa214 + 374e101 commit ed12c18
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 13 deletions.
2 changes: 1 addition & 1 deletion classes/kohana/core.php
Expand Up @@ -16,7 +16,7 @@
class Kohana_Core {

// Release version and codename
const VERSION = '3.1.3';
const VERSION = '3.1.3.1';
const CODENAME = 'araea';

// Common environment type constants for consistency and convenience
Expand Down
11 changes: 2 additions & 9 deletions classes/kohana/request.php
Expand Up @@ -863,11 +863,7 @@ public function uri(array $params = NULL)

$uri = $this->_route->uri($params);

if ( ! $query = $this->query())
return $uri;
else
return $uri . '?' . http_build_query($query, NULL, '&');

return $uri;
}

/**
Expand All @@ -886,10 +882,7 @@ public function url(array $params = NULL, $protocol = NULL)
// Create a URI with the current route and convert it to a URL
$url = URL::site($this->uri($params), $protocol);

if ( ! $query = $this->query())
return $url;
else
return $url . '?' . http_build_query($query, NULL, '&');
return $url;
}

/**
Expand Down
21 changes: 19 additions & 2 deletions classes/kohana/request/client/external.php
Expand Up @@ -218,6 +218,9 @@ protected function _http_execute(Request $request)
// Set the body
$http_request->setBody($request->body());

// Set the query
$http_request->setQueryData($request->query());

try
{
$http_request->send();
Expand Down Expand Up @@ -292,8 +295,15 @@ protected function _curl_execute(Request $request)
// Apply any additional options set to Request_Client_External::$_options
$options += $this->_options;

$uri = $request->uri();

if ($query = $request->query())
{
$uri .= '?'.http_build_query($query, NULL, '&');
}

// Open a new remote connection
$curl = curl_init($request->uri());
$curl = curl_init($uri);

// Set connection options
if ( ! curl_setopt_array($curl, $options))
Expand Down Expand Up @@ -373,7 +383,14 @@ protected function _native_execute(Request $request)

stream_context_set_option($context, $this->_options);

$stream = fopen($request->uri(), $mode, FALSE, $context);
$uri = $request->uri();

if ($query = $request->query())
{
$uri .= '?'.http_build_query($query, NULL, '&');
}

$stream = fopen($uri, $mode, FALSE, $context);

$meta_data = stream_get_meta_data($stream);

Expand Down
2 changes: 1 addition & 1 deletion classes/kohana/session.php
Expand Up @@ -316,7 +316,7 @@ public function read($id = NULL)
}
else
{
Kohana::$log->add(Log::ERROR, 'Error reading session data: '.$id);
// Ignore these, session is valid, likely no data though.
}
}
catch (Exception $e)
Expand Down
44 changes: 44 additions & 0 deletions tests/kohana/RequestTest.php
Expand Up @@ -806,4 +806,48 @@ public function test_query_parameter_parsing(Request $request, $query, $expected

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

/**
* Provider for test_uri_without_query_parameters
*
* @return array
*/
public function provider_uri_without_query_parameters()
{
return array(
array(
new Request('foo/bar?foo=bar&bar=foo'),
array(),
'foo/bar'
),
array(
new Request('foo/bar'),
array('bar' => 'foo', 'foo' => 'bar'),
'foo/bar'
),
array(
new Request('foo/bar'),
array(),
'foo/bar'
)
);
}

/**
* Tests that the [Request::uri()] method does not return
* query parameters
*
* @dataProvider provider_uri_without_query_parameters
*
* @param Request request
* @param array query
* @param string expected
* @return void
*/
public function test_uri_without_query_parameters(Request $request, $query, $expected)
{
$request->query($query);

$this->assertSame($expected, $request->uri());
}
} // End Kohana_RequestTest

0 comments on commit ed12c18

Please sign in to comment.