Skip to content

Commit

Permalink
Changing SCRIPT_NAME to PHP_SELF
Browse files Browse the repository at this point in the history
Several shared hosts have issues with SCRIPT_NAME having an incorrect value.
Revert back to using PHP_SELF like in 1.3.

Fixes #2437
Fixes #2334
Fixes #2268
  • Loading branch information
markstory committed Jan 5, 2012
1 parent 3e1c567 commit 95ec741
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Network/CakeRequest.php
Expand Up @@ -249,7 +249,7 @@ protected function _base() {
}

if (!$baseUrl) {
$base = dirname(env('SCRIPT_NAME'));
$base = dirname(env('PHP_SELF'));

if ($webroot === 'webroot' && $webroot === basename($base)) {
$base = dirname($base);
Expand Down
18 changes: 9 additions & 9 deletions lib/Cake/Test/Case/Network/CakeRequestTest.php
Expand Up @@ -891,7 +891,7 @@ public function testBaseUrlAndWebrootWithModRewrite() {
Configure::write('App.baseUrl', false);

$_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches';
$_SERVER['SCRIPT_NAME'] = '/1.2.x.x/app/webroot/index.php';
$_SERVER['PHP_SELF'] = '/1.2.x.x/app/webroot/index.php';
$_SERVER['PATH_INFO'] = '/posts/view/1';

$request = new CakeRequest();
Expand All @@ -901,7 +901,7 @@ public function testBaseUrlAndWebrootWithModRewrite() {


$_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches/1.2.x.x/app/webroot';
$_SERVER['SCRIPT_NAME'] = '/index.php';
$_SERVER['PHP_SELF'] = '/index.php';
$_SERVER['PATH_INFO'] = '/posts/add';
$request = new CakeRequest();

Expand All @@ -910,15 +910,15 @@ public function testBaseUrlAndWebrootWithModRewrite() {
$this->assertEquals($request->url, 'posts/add');

$_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches/1.2.x.x/test/';
$_SERVER['SCRIPT_NAME'] = '/webroot/index.php';
$_SERVER['PHP_SELF'] = '/webroot/index.php';
$request = new CakeRequest();

$this->assertEquals('', $request->base);
$this->assertEquals('/', $request->webroot);


$_SERVER['DOCUMENT_ROOT'] = '/some/apps/where';
$_SERVER['SCRIPT_NAME'] = '/app/webroot/index.php';
$_SERVER['PHP_SELF'] = '/app/webroot/index.php';
$request = new CakeRequest();

$this->assertEquals($request->base, '');
Expand All @@ -927,7 +927,7 @@ public function testBaseUrlAndWebrootWithModRewrite() {
Configure::write('App.dir', 'auth');

$_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches';
$_SERVER['SCRIPT_NAME'] = '/demos/auth/webroot/index.php';
$_SERVER['PHP_SELF'] = '/demos/auth/webroot/index.php';

$request = new CakeRequest();

Expand All @@ -937,7 +937,7 @@ public function testBaseUrlAndWebrootWithModRewrite() {
Configure::write('App.dir', 'code');

$_SERVER['DOCUMENT_ROOT'] = '/Library/WebServer/Documents';
$_SERVER['SCRIPT_NAME'] = '/clients/PewterReport/code/webroot/index.php';
$_SERVER['PHP_SELF'] = '/clients/PewterReport/code/webroot/index.php';
$request = new CakeRequest();

$this->assertEquals($request->base, '/clients/PewterReport/code');
Expand All @@ -951,7 +951,7 @@ public function testBaseUrlAndWebrootWithModRewrite() {
*/
public function testBaseUrlwithModRewriteAlias() {
$_SERVER['DOCUMENT_ROOT'] = '/home/aplusnur/public_html';
$_SERVER['SCRIPT_NAME'] = '/control/index.php';
$_SERVER['PHP_SELF'] = '/control/index.php';

Configure::write('App.base', '/control');

Expand All @@ -965,7 +965,7 @@ public function testBaseUrlwithModRewriteAlias() {
Configure::write('App.webroot', 'newaffiliate');

$_SERVER['DOCUMENT_ROOT'] = '/var/www/abtravaff/html';
$_SERVER['SCRIPT_NAME'] = '/newaffiliate/index.php';
$_SERVER['PHP_SELF'] = '/newaffiliate/index.php';
$request = new CakeRequest();

$this->assertEquals($request->base, '/newaffiliate');
Expand Down Expand Up @@ -1106,7 +1106,7 @@ public function testBaseUrlNoRewriteWebrootIndex() {
*/
public function testGetParamsWithDot() {
$_GET['/posts/index/add_add'] = '';
$_SERVER['SCRIPT_NAME'] = '/cake_dev/app/webroot/index.php';
$_SERVER['PHP_SELF'] = '/cake_dev/app/webroot/index.php';
$_SERVER['REQUEST_URI'] = '/cake_dev/posts/index/add.add';

$request = new CakeRequest();
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Routing/DispatcherTest.php
Expand Up @@ -877,7 +877,7 @@ public function testPluginDispatch() {
*/
public function testAutomaticPluginDispatch() {
$_POST = array();
$_SERVER['SCRIPT_NAME'] = '/cake/repo/branches/1.2.x.x/index.php';
$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';

Router::reload();
$Dispatcher = new TestDispatcher();
Expand Down

0 comments on commit 95ec741

Please sign in to comment.