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:
mark_story 2011-12-02 23:39:33 -05:00
parent d4fd1b3743
commit 22352a0227
2 changed files with 25 additions and 2 deletions

View file

@ -278,10 +278,10 @@ class CakeRequest implements ArrayAccess {
$docRootContainsWebroot = strpos($docRoot, $dir . '/' . $webroot);
if (!empty($base) || !$docRootContainsWebroot) {
if (strpos($this->webroot, $dir) === false) {
if (strpos($this->webroot, '/' . $dir . '/') === false) {
$this->webroot .= $dir . '/' ;
}
if (strpos($this->webroot, $webroot) === false) {
if (strpos($this->webroot, '/' . $webroot . '/') === false) {
$this->webroot .= $webroot . '/';
}
}

View file

@ -1041,6 +1041,29 @@ class CakeRequestTest extends CakeTestCase {
$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.
*