diff --git a/classes/kohana/core.php b/classes/kohana/core.php index 4b8eccebe..be3314aa2 100644 --- a/classes/kohana/core.php +++ b/classes/kohana/core.php @@ -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 diff --git a/classes/kohana/request.php b/classes/kohana/request.php index 4cd8366cf..eddd2d7a2 100644 --- a/classes/kohana/request.php +++ b/classes/kohana/request.php @@ -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; } /** @@ -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; } /** diff --git a/classes/kohana/request/client/external.php b/classes/kohana/request/client/external.php index 8f6b73cdc..86fb5ef4f 100644 --- a/classes/kohana/request/client/external.php +++ b/classes/kohana/request/client/external.php @@ -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(); @@ -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)) @@ -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); diff --git a/classes/kohana/session.php b/classes/kohana/session.php index bc67d2c63..64be88c99 100644 --- a/classes/kohana/session.php +++ b/classes/kohana/session.php @@ -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) diff --git a/tests/kohana/RequestTest.php b/tests/kohana/RequestTest.php index 4c22fc475..e772aed7f 100644 --- a/tests/kohana/RequestTest.php +++ b/tests/kohana/RequestTest.php @@ -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 \ No newline at end of file