Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.0' into 2.0-class-loading
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Feb 22, 2011
2 parents a9d2078 + 6426b7e commit 688e914
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 16 deletions.
22 changes: 11 additions & 11 deletions lib/Cake/Network/CakeRequest.php
Expand Up @@ -189,18 +189,18 @@ protected function _processGet() {
* @return string URI The CakePHP request path that is being accessed.
*/
protected function _url() {
$pathInfo = env('PATH_INFO');
if (!empty($pathInfo)) {
return $pathInfo;
}
foreach (array('PHP_SELF', 'REQUEST_URI', 'HTTP_X_REWRITE_URL', 'argv') as $var) {
if ($uri = env($var)) {
if ($var == 'argv') {
$uri = $url[0];
}
break;
}
if (!empty($_SERVER['PATH_INFO'])) {
return $_SERVER['PATH_INFO'];
} elseif (isset($_SERVER['REQUEST_URI'])) {
$uri = $_SERVER['REQUEST_URI'];
} elseif (isset($_SERVER['PHP_SELF']) && isset($_SERVER['SCRIPT_NAME'])) {
$uri = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['PHP_SELF']);
} elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
$uri = $_SERVER['HTTP_X_REWRITE_URL'];
} elseif ($var = env('argv')) {
$uri = $var[0];
}

$base = $this->base;

if (strpos($uri, $base) === 0) {
Expand Down
58 changes: 53 additions & 5 deletions lib/Cake/tests/cases/libs/cake_request.test.php
Expand Up @@ -1173,7 +1173,7 @@ public static function environmentGenerator() {
),
),
array(
'Apache - No rewrite, document root set above top level cake dir, requesting root',
'Apache - No rewrite, document root set above top level cake dir, reques root, no PATH_INFO',
array(
'App' => array(
'base' => false,
Expand All @@ -1185,9 +1185,8 @@ public static function environmentGenerator() {
'SERVER_NAME' => 'localhost',
'DOCUMENT_ROOT' => '/Library/WebServer/Documents',
'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php',
'REQUEST_URI' => '/site/index.php/',
'REQUEST_URI' => '/site/index.php/',
'SCRIPT_NAME' => '/site/index.php',
'PATH_INFO' => '',
'PHP_SELF' => '/site/index.php/',
),
),
Expand Down Expand Up @@ -1224,7 +1223,56 @@ public static function environmentGenerator() {
'base' => '/site/index.php',
'webroot' => '/site/app/webroot/',
),
)
),
array(
'Apache - w/rewrite, document root set above top level cake dir, request root, no PATH_INFO',
array(
'App' => array(
'base' => false,
'baseUrl' => false,
'dir' => 'app',
'webroot' => 'webroot'
),
'SERVER' => array(
'SERVER_NAME' => 'localhost',
'DOCUMENT_ROOT' => '/Library/WebServer/Documents',
'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php',
'REQUEST_URI' => '/site/',
'SCRIPT_NAME' => '/site/app/webroot/index.php',
'PHP_SELF' => '/site/app/webroot/index.php',
),
),
array(
'url' => '',
'base' => '/site',
'webroot' => '/site/',
),
),
array(
'Apache - w/rewrite, document root above top level cake dir, request root, no PATH_INFO/REQUEST_URI',
array(
'App' => array(
'base' => false,
'baseUrl' => false,
'dir' => 'app',
'webroot' => 'webroot'
),
'SERVER' => array(
'SERVER_NAME' => 'localhost',
'DOCUMENT_ROOT' => '/Library/WebServer/Documents',
'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php',
'SCRIPT_NAME' => '/site/app/webroot/index.php',
'PHP_SELF' => '/site/app/webroot/index.php',
'PATH_INFO' => null,
'REQUEST_URI' => null,
),
),
array(
'url' => '',
'base' => '/site',
'webroot' => '/site/',
),
),
);
}

Expand All @@ -1240,7 +1288,7 @@ public function testEnvironmentDetection($name, $env, $expected) {
$request = new CakeRequest();
$this->assertEquals($expected['url'], $request->url, "url error");
$this->assertEquals($expected['base'], $request->base, "base error");
$this->assertEquals($expected['webroot'],$request->webroot, "webroot error");
$this->assertEquals($expected['webroot'], $request->webroot, "webroot error");
if (isset($expected['urlParams'])) {
$this->assertEqual($_GET, $expected['urlParams'], "GET param mismatch");
}
Expand Down

0 comments on commit 688e914

Please sign in to comment.