mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Move CakeSession database configuration to separate method, cutting down init().
This commit is contained in:
parent
632d1f13ae
commit
34a6808d5d
1 changed files with 32 additions and 22 deletions
|
@ -148,28 +148,7 @@ class CakeSession {
|
|||
self::$_userAgent = md5(env('HTTP_USER_AGENT') . Configure::read('Security.salt'));
|
||||
}
|
||||
|
||||
if (Configure::read('Session.save') === 'database') {
|
||||
$modelName = Configure::read('Session.model');
|
||||
$database = Configure::read('Session.database');
|
||||
$table = Configure::read('Session.table');
|
||||
|
||||
if (empty($database)) {
|
||||
$database = 'default';
|
||||
}
|
||||
$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);
|
||||
}
|
||||
self::_setupDatabase();
|
||||
if ($start === true) {
|
||||
if (empty($base)) {
|
||||
self::$path = '/';
|
||||
|
@ -194,6 +173,37 @@ class CakeSession {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup database configuration for Session, if enabled.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _setupDatabase() {
|
||||
if (Configure::read('Session.save') !== 'database') {
|
||||
return;
|
||||
}
|
||||
$modelName = Configure::read('Session.model');
|
||||
$database = Configure::read('Session.database');
|
||||
$table = Configure::read('Session.table');
|
||||
|
||||
if (empty($database)) {
|
||||
$database = 'default';
|
||||
}
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the Session.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue