mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge remote-tracking branch 'origin/2.0' into 2.0-class-loading
This commit is contained in:
commit
688e914381
2 changed files with 64 additions and 16 deletions
|
@ -189,18 +189,18 @@ class CakeRequest implements ArrayAccess {
|
|||
* @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) {
|
||||
|
|
|
@ -1173,7 +1173,7 @@ class CakeRequestTestCase extends CakeTestCase {
|
|||
),
|
||||
),
|
||||
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,
|
||||
|
@ -1185,9 +1185,8 @@ class CakeRequestTestCase extends CakeTestCase {
|
|||
'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/',
|
||||
),
|
||||
),
|
||||
|
@ -1224,7 +1223,56 @@ class CakeRequestTestCase extends CakeTestCase {
|
|||
'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/',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1240,7 +1288,7 @@ class CakeRequestTestCase extends CakeTestCase {
|
|||
$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");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue