Skip to content

Commit

Permalink
Removing routing url from query string in CakeRequest. This happens m…
Browse files Browse the repository at this point in the history
…ostly with nginx setups
  • Loading branch information
lorenzo committed Aug 27, 2011
1 parent 7d0250f commit f94394f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/Cake/Network/CakeRequest.php
Expand Up @@ -180,6 +180,7 @@ protected function _processGet() {
$query = $_GET;
}

unset($query['/' . $this->url]);
if (strpos($this->url, '?') !== false) {
list(, $querystr) = explode('?', $this->url);
parse_str($querystr, $queryArgs);
Expand Down
30 changes: 29 additions & 1 deletion lib/Cake/Test/Case/Network/CakeRequestTest.php
Expand Up @@ -1325,6 +1325,34 @@ public static function environmentGenerator() {
'webroot' => '/',
),
),
array(
'Nginx - w/rewrite, document root set to webroot, request root, no PATH_INFO',
array(
'App' => array(
'base' => false,
'baseUrl' => false,
'dir' => 'app',
'webroot' => 'webroot'
),
'GET' => array('/posts/add' => ''),
'SERVER' => array(
'SERVER_NAME' => 'localhost',
'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/app/webroot',
'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php',
'SCRIPT_NAME' => '/index.php',
'QUERY_STRING' => '/posts/add&',
'PHP_SELF' => '/index.php',
'PATH_INFO' => null,
'REQUEST_URI' => '/posts/add',
),
),
array(
'url' => 'posts/add',
'base' => '',
'webroot' => '/',
'urlParams' => array()
),
),
);
}

Expand All @@ -1343,7 +1371,7 @@ public function testEnvironmentDetection($name, $env, $expected) {
$this->assertEquals($expected['base'], $request->base, "base error");
$this->assertEquals($expected['webroot'], $request->webroot, "webroot error");
if (isset($expected['urlParams'])) {
$this->assertEqual($_GET, $expected['urlParams'], "GET param mismatch");
$this->assertEqual($request->query, $expected['urlParams'], "GET param mismatch");
}
}

Expand Down

0 comments on commit f94394f

Please sign in to comment.