Making Session.model the required setting and not Session.table. Session.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

This commit is contained in:
Mark Story 2010-01-21 11:59:49 -05:00
parent 913450daef
commit c5a5d1dfe6
2 changed files with 17 additions and 16 deletions

View file

@ -138,17 +138,19 @@ class CakeSession extends Object {
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 @@ class CakeSession extends Object {
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 @@ class CakeSession extends Object {
$model =& ClassRegistry::getObject('Session');
$return = $model->save(compact('id', 'data', 'expires'));
return $return;
}

View file

@ -431,7 +431,8 @@ class CakeSessionTest extends CakeTestCase {
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 @@ class CakeSessionTest extends CakeTestCase {
Configure::write('Session.save', 'php');
$this->setUp();
}
}
?>