Skip to content
Permalink
Browse files

Making Session.model the required setting and not Session.table. Sess…

…ion.table can still be used to set the table name used when configuring sessions, but the default value is cake_session as before. Fixes #223
  • Loading branch information...
markstory committed Jan 21, 2010
1 parent 913450d commit c5a5d1dfe6b902e2ecc219a6b480dcf36aeb970e
Showing with 17 additions and 16 deletions.
  1. +14 −15 cake/libs/cake_session.php
  2. +3 −1 cake/tests/cases/libs/cake_session.test.php
@@ -138,17 +138,19 @@ function __construct($base = null, $start = true) {
if (empty($database)) {
$database = 'default';
}
if (empty($modelName)) {
ClassRegistry::init(array(
'class' => Inflector::classify($table),
'alias' => 'Session'
));
} else {
ClassRegistry::init(array(
'class' => $modelName,
'alias' => 'Session'
));
$settings = array(
'class' => 'Session',
'alias' => 'Session',
'table' => 'cake_sessions',
'ds' => $database
);
if (!empty($modelName)) {
$settings['class'] = $modelName;
}
if (!empty($table)) {
$settings['table'] = $table;
}
ClassRegistry::init($settings);
}
if ($start === true) {
if (!empty($base)) {
@@ -492,11 +494,9 @@ function __initSession() {
break;
case 'database':
if (empty($_SESSION)) {
if (Configure::read('Session.table') === null) {
if (Configure::read('Session.model') === null) {
trigger_error(__("You must set the all Configure::write('Session.*') in core.php to use database storage"), E_USER_WARNING);
exit();
} elseif (Configure::read('Session.database') === null) {
Configure::write('Session.database', 'default');
$this->_stop();
}
if ($iniSet) {
ini_set('session.use_trans_sid', 0);
@@ -763,7 +763,6 @@ function __write($id, $data) {
$model =& ClassRegistry::getObject('Session');
$return = $model->save(compact('id', 'data', 'expires'));
return $return;
}
@@ -431,7 +431,8 @@ function testReadAndWriteWithDatabaseStorage() {
unset($_SESSION);
session_destroy();
Configure::write('Session.table', 'sessions');
Configure::write('Session.database', 'test');
Configure::write('Session.model', 'Session');
Configure::write('Session.database', 'test_suite');
Configure::write('Session.save', 'database');
$this->setUp();
@@ -463,5 +464,6 @@ function testReadAndWriteWithDatabaseStorage() {
Configure::write('Session.save', 'php');
$this->setUp();
}
}
?>

0 comments on commit c5a5d1d

Please sign in to comment.
You can’t perform that action at this time.