mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 12:36:25 +00:00
Moving _setupDatabase() into the Database session class, as that's the only place its used.
This commit is contained in:
parent
c8ad4f11eb
commit
d54c901f5d
2 changed files with 30 additions and 32 deletions
|
@ -149,7 +149,6 @@ class CakeSession {
|
||||||
self::$_userAgent = md5(env('HTTP_USER_AGENT') . Configure::read('Security.salt'));
|
self::$_userAgent = md5(env('HTTP_USER_AGENT') . Configure::read('Security.salt'));
|
||||||
}
|
}
|
||||||
|
|
||||||
self::_setupDatabase();
|
|
||||||
if ($start === true) {
|
if ($start === true) {
|
||||||
self::_setPath($base);
|
self::_setPath($base);
|
||||||
self::_setHost(env('HTTP_HOST'));
|
self::_setHost(env('HTTP_HOST'));
|
||||||
|
@ -192,37 +191,6 @@ class CakeSession {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Setup database configuration for Session, if enabled.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function _setupDatabase() {
|
|
||||||
if (Configure::read('Session.defaults') !== 'database') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$modelName = Configure::read('Session.handler.model');
|
|
||||||
$database = Configure::read('Session.handler.database');
|
|
||||||
$table = Configure::read('Session.handler.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.
|
* Starts the Session.
|
||||||
*
|
*
|
||||||
|
|
|
@ -23,6 +23,36 @@
|
||||||
* @package cake.libs
|
* @package cake.libs
|
||||||
*/
|
*/
|
||||||
class DatabaseSession implements CakeSessionHandlerInterface {
|
class DatabaseSession implements CakeSessionHandlerInterface {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor. Looks at Session configuration information and
|
||||||
|
* sets up the session model.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function __construct() {
|
||||||
|
$modelName = Configure::read('Session.handler.model');
|
||||||
|
$database = Configure::read('Session.handler.database');
|
||||||
|
$table = Configure::read('Session.handler.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);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method called on open of a database session.
|
* Method called on open of a database session.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue