Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed implementation of SessionHandlerInterface in Mage_Core_Model_Resource_Session #3499

Merged
merged 9 commits into from
Sep 8, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions app/code/core/Mage/Core/Model/Resource/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ public static function setStaticSaveHandler()
* @param string $sessName ignored
* @return bool
*/
#[\ReturnTypeWillChange]
public function open($savePath, $sessName)
public function open($savePath, $sessName): bool
{
return true;
}
Expand All @@ -173,8 +172,7 @@ public function open($savePath, $sessName)
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function close()
public function close(): bool
{
$this->gc($this->getLifeTime());

Expand All @@ -185,10 +183,9 @@ public function close()
* Fetch session data
*
* @param string $sessId
* @return string
* @return string|false
*/
#[\ReturnTypeWillChange]
public function read($sessId)
public function read($sessId): string|false
fballiano marked this conversation as resolved.
Show resolved Hide resolved
{
$select = $this->_read->select()
->from($this->_sessionTable, ['session_data'])
Expand All @@ -211,8 +208,7 @@ public function read($sessId)
* @param string $sessData
* @return bool
*/
#[\ReturnTypeWillChange]
public function write($sessId, $sessData)
public function write($sessId, $sessData): bool
{
$bindValues = [
'session_id' => $sessId
Expand Down Expand Up @@ -245,8 +241,7 @@ public function write($sessId, $sessData)
* @param string $sessId
* @return bool
*/
#[\ReturnTypeWillChange]
public function destroy($sessId)
public function destroy($sessId): bool
{
$where = ['session_id = ?' => $sessId];
$this->_write->delete($this->_sessionTable, $where);
Expand All @@ -257,19 +252,18 @@ public function destroy($sessId)
* Garbage collection
*
* @param int $sessMaxLifeTime ignored
* @return bool
* @return int|false
*/
#[\ReturnTypeWillChange]
public function gc($sessMaxLifeTime)
public function gc($sessMaxLifeTime): int|false
{
if ($this->_automaticCleaningFactor > 0) {
if ($this->_automaticCleaningFactor == 1 ||
rand(1, $this->_automaticCleaningFactor) == 1
) {
$where = ['session_expires < ?' => Varien_Date::toTimestamp(true)];
$this->_write->delete($this->_sessionTable, $where);
return $this->_write->delete($this->_sessionTable, $where);
}
}
return true;
return false;
fballiano marked this conversation as resolved.
Show resolved Hide resolved
fballiano marked this conversation as resolved.
Show resolved Hide resolved
}
}