Skip to content

Commit

Permalink
Fix bugs with Session DB Save Handler: (#4)
Browse files Browse the repository at this point in the history
- True is returned when updating the session, even if the session DB record was not actually updated.
- True is always returned when destroying the session, even if the session was already deleted from the DB.
  • Loading branch information
kirkbaly authored Feb 4, 2022
1 parent 4f3a2d2 commit e39caf5
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions packages/zend-session/library/Zend/Session/SaveHandler/DbTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,45 +337,36 @@ public function read($id)
*/
public function write($id, $data)
{
$return = false;

$data = array($this->_modifiedColumn => time(),
$this->_dataColumn => (string) $data);

$rows = call_user_func_array(array(&$this, 'find'), $this->_getPrimary($id));

if (count($rows)) {
$data[$this->_lifetimeColumn] = $this->_getLifetime($rows->current());

if ($this->update($data, $this->_getPrimary($id, self::PRIMARY_TYPE_WHERECLAUSE))) {
$return = true;
}
$this->update($data, $this->_getPrimary($id, self::PRIMARY_TYPE_WHERECLAUSE));
return true;
} else {
$data[$this->_lifetimeColumn] = $this->_lifetime;

if ($this->insert(array_merge($this->_getPrimary($id, self::PRIMARY_TYPE_ASSOC), $data))) {
$return = true;
return true;
}
}

return $return;
return false;
}

/**
* Destroy session
*
* @param string $id
* @return boolean
* @return true
*/
public function destroy($id)
{
$return = false;

if ($this->delete($this->_getPrimary($id, self::PRIMARY_TYPE_WHERECLAUSE))) {
$return = true;
}

return $return;
$this->delete($this->_getPrimary($id, self::PRIMARY_TYPE_WHERECLAUSE));
return true;
}

/**
Expand Down

0 comments on commit e39caf5

Please sign in to comment.