Skip to content

Commit bbb5642

Browse files
author
gwoo
committed
Merge branch 'local/svn/1.2.x.x' into 1.2
2 parents 5749893 + f983340 commit bbb5642

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

cake/libs/session.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,23 @@ function __construct($base = null, $start = true) {
137137
$this->time = time();
138138

139139
if ($start === true) {
140-
$this->host = env('HTTP_HOST');
141-
$this->path = '/';
142-
if (strpos($base, '?') === false && strpos($base, 'index.php') === false) {
140+
if (!empty($base)) {
143141
$this->path = $base;
142+
if (strpos($base, 'index.php') !== false) {
143+
$this->path = str_replace('index.php', '', $base);
144+
}
145+
if (strpos($base, '?') !== false) {
146+
$this->path = str_replace('?', '', $base);
147+
}
144148
}
149+
$this->host = env('HTTP_HOST');
145150

146151
if (strpos($this->host, ':') !== false) {
147152
$this->host = substr($this->host, 0, strpos($this->host, ':'));
148153
}
149-
150154
if (!class_exists('Security')) {
151155
App::import('Core', 'Security');
152156
}
153-
154157
$this->sessionTime = $this->time + (Security::inactiveMins() * Configure::read('Session.timeout'));
155158
$this->security = Configure::read('Security.level');
156159
}

cake/tests/cases/dispatcher.test.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ class DispatcherTest extends CakeTestCase {
493493
* @access public
494494
* @return void
495495
*/
496-
function setUp() {
496+
function startTest() {
497497
$this->_get = $_GET;
498498
$_GET = array();
499499
$this->_post = $_POST;
@@ -512,15 +512,19 @@ function setUp() {
512512
$this->_vendorPaths = Configure::read('vendorPaths');
513513
$this->_pluginPaths = Configure::read('pluginPaths');
514514
$this->_viewPaths = Configure::read('viewPaths');
515+
$this->_controllerPaths = Configure::read('controllerPaths');
515516
$this->_debug = Configure::read('debug');
517+
518+
Configure::write('controllerPaths', Configure::corePaths('controller'));
519+
Configure::write('viewPaths', Configure::corePaths('view'));
516520
}
517521
/**
518522
* tearDown method
519523
*
520524
* @access public
521525
* @return void
522526
*/
523-
function tearDown() {
527+
function endTest() {
524528
$_GET = $this->_get;
525529
$_POST = $this->_post;
526530
$_FILES = $this->_files;
@@ -530,6 +534,7 @@ function tearDown() {
530534
Configure::write('vendorPaths', $this->_vendorPaths);
531535
Configure::write('pluginPaths', $this->_pluginPaths);
532536
Configure::write('viewPaths', $this->_viewPaths);
537+
Configure::write('controllerPaths', $this->_controllerPaths);
533538
Configure::write('debug', $this->_debug);
534539
}
535540
/**

cake/tests/cases/libs/session.test.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ function setUp() {
7676
function testSessionPath() {
7777
$Session = new CakeSession('/index.php');
7878
$this->assertEqual('/', $Session->path);
79+
80+
$Session = new CakeSession('/sub_dir/index.php');
81+
$this->assertEqual('/sub_dir/', $Session->path);
82+
83+
$Session = new CakeSession('');
84+
$this->assertEqual('/', $Session->path, 'Session path is empty, with "" as $base needs to be / %s');
7985
}
8086
/**
8187
* testCheck method

0 commit comments

Comments
 (0)