Permalink
Browse files

Changing SCRIPT_NAME to PHP_SELF

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...
1 parent 3e1c567 commit 95ec741b6c194da93b4b9f7ed491e5a5ca492b09 @markstory markstory committed Jan 5, 2012
View
2 lib/Cake/Network/CakeRequest.php
@@ -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);
View
18 lib/Cake/Test/Case/Network/CakeRequestTest.php
@@ -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();
@@ -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();
@@ -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, '');
@@ -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();
@@ -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');
@@ -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');
@@ -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');
@@ -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();
View
2 lib/Cake/Test/Case/Routing/DispatcherTest.php
@@ -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();

0 comments on commit 95ec741

Please sign in to comment.