mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Fix missing directory in dispatcher with rewrite off.
When re-writing is disabled, and the deployment directory contains either 'app' or 'webroot' the computed path was incorrect. Fixes #2330
This commit is contained in:
parent
d4fd1b3743
commit
22352a0227
2 changed files with 25 additions and 2 deletions
|
@ -278,10 +278,10 @@ class CakeRequest implements ArrayAccess {
|
||||||
$docRootContainsWebroot = strpos($docRoot, $dir . '/' . $webroot);
|
$docRootContainsWebroot = strpos($docRoot, $dir . '/' . $webroot);
|
||||||
|
|
||||||
if (!empty($base) || !$docRootContainsWebroot) {
|
if (!empty($base) || !$docRootContainsWebroot) {
|
||||||
if (strpos($this->webroot, $dir) === false) {
|
if (strpos($this->webroot, '/' . $dir . '/') === false) {
|
||||||
$this->webroot .= $dir . '/' ;
|
$this->webroot .= $dir . '/' ;
|
||||||
}
|
}
|
||||||
if (strpos($this->webroot, $webroot) === false) {
|
if (strpos($this->webroot, '/' . $webroot . '/') === false) {
|
||||||
$this->webroot .= $webroot . '/';
|
$this->webroot .= $webroot . '/';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1041,6 +1041,29 @@ class CakeRequestTest extends CakeTestCase {
|
||||||
$this->assertEquals('/app/webroot/', $request->webroot);
|
$this->assertEquals('/app/webroot/', $request->webroot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check that a sub-directory containing app|webroot doesn't get mishandled when re-writing is off.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testBaseUrlWithAppAndWebrootInDirname() {
|
||||||
|
Configure::write('App.baseUrl', '/approval/index.php');
|
||||||
|
$_SERVER['DOCUMENT_ROOT'] = '/Users/markstory/Sites/';
|
||||||
|
$_SERVER['SCRIPT_FILENAME'] = '/Users/markstory/Sites/approval/index.php';
|
||||||
|
|
||||||
|
$request = new CakeRequest();
|
||||||
|
$this->assertEquals('/approval/index.php', $request->base);
|
||||||
|
$this->assertEquals('/approval/app/webroot/', $request->webroot);
|
||||||
|
|
||||||
|
Configure::write('App.baseUrl', '/webrootable/index.php');
|
||||||
|
$_SERVER['DOCUMENT_ROOT'] = '/Users/markstory/Sites/';
|
||||||
|
$_SERVER['SCRIPT_FILENAME'] = '/Users/markstory/Sites/webrootable/index.php';
|
||||||
|
|
||||||
|
$request = new CakeRequest();
|
||||||
|
$this->assertEquals('/webrootable/index.php', $request->base);
|
||||||
|
$this->assertEquals('/webrootable/app/webroot/', $request->webroot);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test baseUrl with no rewrite, and using the app/webroot/index.php file as is normal with virtual hosts.
|
* test baseUrl with no rewrite, and using the app/webroot/index.php file as is normal with virtual hosts.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue