Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit c5a5d1dfe6b902e2ecc219a6b480dcf36aeb970e 1 parent 913450d
@markstory markstory authored
View
29 cake/libs/cake_session.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;
}
View
4 cake/tests/cases/libs/cake_session.test.php
@@ -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();
}
+
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.