Adding fix for Ticket #910 (broken db sessions)

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3140 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2006-06-19 16:15:49 +00:00
parent 6cca0d00ea
commit 85d5fe3bba
3 changed files with 20 additions and 6 deletions

View file

@ -190,6 +190,15 @@ class ConnectionManager extends Object {
$this->cakeError('missingConnection', array(array('className' => 'ConnectionManager')));
}
}
/**
* Destructor.
*
*/
function __destruct() {
if (CAKE_SESSION_SAVE == 'database' && function_exists('session_write_close')) {
session_write_close();
}
}
}
?>

View file

@ -399,9 +399,10 @@ class DboSource extends DataSource {
* Gets full table name including prefix
*
* @param mixed $model
* @param boolean $quote
* @return string Full quoted table name
*/
function fullTableName($model) {
function fullTableName($model, $quote = true) {
if (is_object($model)) {
$table = $model->table;
if ($model->tablePrefix != null && !empty($model->tablePrefix)) {
@ -412,7 +413,10 @@ class DboSource extends DataSource {
} else {
$table = strval($model);
}
return $this->name($table);
if ($quote) {
return $this->name($table);
}
return $table;
}
/**
* The "C" in CRUD

View file

@ -423,11 +423,11 @@ class CakeSession extends Object{
*/
function __read($key) {
$db =& ConnectionManager::getDataSource('default');
$table = $db->fullTableName(CAKE_SESSION_TABLE);
$table = $db->fullTableName(CAKE_SESSION_TABLE, false);
$row = $db->query("SELECT " . $db->name($table.'.data') . " FROM " . $db->name($table) . " WHERE " . $db->name($table.'.id') . " = " . $db->value($key), false);
if ($row && $row[0][CAKE_SESSION_TABLE]['data']) {
return $row[0][CAKE_SESSION_TABLE]['data'];
if ($row && $row[0][$table]['data']) {
return $row[0][$table]['data'];
} else {
return false;
}
@ -520,7 +520,7 @@ class CakeSession extends Object{
*/
function __write($key, $value) {
$db =& ConnectionManager::getDataSource('default');
$table = $db->fullTableName(CAKE_SESSION_TABLE);
$table = $db->fullTableName(CAKE_SESSION_TABLE, false);
switch(CAKE_SECURITY) {
case 'high':
@ -555,4 +555,5 @@ class CakeSession extends Object{
return true;
}
}
?>