diff --git a/app/code/core/Mage/Core/Model/Resource/Session.php b/app/code/core/Mage/Core/Model/Resource/Session.php index 0427f2a5258..1092aab6786 100644 --- a/app/code/core/Mage/Core/Model/Resource/Session.php +++ b/app/code/core/Mage/Core/Model/Resource/Session.php @@ -71,10 +71,6 @@ public function __construct() $this->_write = $resource->getConnection('core_write'); } - /** - * Destrucor - * - */ public function __destruct() { session_write_close(); @@ -162,8 +158,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; } @@ -173,8 +168,7 @@ public function open($savePath, $sessName) * * @return bool */ - #[\ReturnTypeWillChange] - public function close() + public function close(): bool { $this->gc($this->getLifeTime()); @@ -187,21 +181,18 @@ public function close() * @param string $sessId * @return string */ - #[\ReturnTypeWillChange] - public function read($sessId) + public function read($sessId): string|false { $select = $this->_read->select() - ->from($this->_sessionTable, ['session_data']) - ->where('session_id = :session_id') - ->where('session_expires > :session_expires'); + ->from($this->_sessionTable, ['session_data']) + ->where('session_id = :session_id') + ->where('session_expires > :session_expires'); $bind = [ 'session_id' => $sessId, 'session_expires' => Varien_Date::toTimestamp(true) ]; - $data = $this->_read->fetchOne($select, $bind); - - return (string)$data; + return $this->_read->fetchOne($select, $bind); } /** @@ -211,15 +202,14 @@ 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 ]; $select = $this->_write->select() - ->from($this->_sessionTable) - ->where('session_id = :session_id'); + ->from($this->_sessionTable) + ->where('session_id = :session_id'); $exists = $this->_read->fetchOne($select, $bindValues); $bind = [ @@ -245,8 +235,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); @@ -257,19 +246,16 @@ 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 - ) { + 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 0; } }