From 4f10ca7b2370192f05d04d6e185cf2896b8a14aa Mon Sep 17 00:00:00 2001 From: Colin Mollenhour Date: Tue, 3 Oct 2023 10:21:02 -0400 Subject: [PATCH] Remove dependency on Zend. Add ReturnTypeWillChange annotation to suppress warnings in PHP 8.2 --- .../community/Cm/RedisSession/Model/Session.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/code/community/Cm/RedisSession/Model/Session.php b/app/code/community/Cm/RedisSession/Model/Session.php index f5ec6da..eac05e0 100644 --- a/app/code/community/Cm/RedisSession/Model/Session.php +++ b/app/code/community/Cm/RedisSession/Model/Session.php @@ -29,7 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -class Cm_RedisSession_Model_Session implements \Zend_Session_SaveHandler_Interface +class Cm_RedisSession_Model_Session implements SessionHandlerInterface { const FLAG_READ_ONLY = 'cm-redissession-read-only'; @@ -96,12 +96,13 @@ public static function setStaticSaveHandler() * @return bool * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ + #[\ReturnTypeWillChange] public function open($savePath, $sessionName) { try { return $this->sessionHandler->open($savePath, $sessionName); } catch (Throwable $e) { - $this->handleException($e); + throw $this->handleException($e); } } @@ -111,6 +112,7 @@ public function open($savePath, $sessionName) * @param string $sessionId * @return string|bool */ + #[\ReturnTypeWillChange] public function read($sessionId) { try { @@ -119,7 +121,7 @@ public function read($sessionId) return $data; } catch (Throwable $e) { self::$failedLockAttempts = $this->sessionHandler->getFailedLockAttempts(); - $this->handleException($e); + throw $this->handleException($e); } } @@ -130,6 +132,7 @@ public function read($sessionId) * @param string $sessionData * @return boolean */ + #[\ReturnTypeWillChange] public function write($sessionId, $sessionData) { return $this->sessionHandler->write($sessionId, $sessionData); @@ -141,6 +144,7 @@ public function write($sessionId, $sessionData) * @param string $sessionId * @return boolean */ + #[\ReturnTypeWillChange] public function destroy($sessionId) { return $this->sessionHandler->destroy($sessionId); @@ -151,6 +155,7 @@ public function destroy($sessionId) * * @return bool */ + #[\ReturnTypeWillChange] public function close() { return $this->sessionHandler->close(); @@ -162,6 +167,7 @@ public function close() * @param int $maxLifeTime ignored * @return boolean */ + #[\ReturnTypeWillChange] public function gc($maxLifeTime) { return $this->sessionHandler->gc($maxLifeTime); @@ -169,7 +175,7 @@ public function gc($maxLifeTime) /** * @param Throwable $e - * @return void + * @return Throwable */ protected function handleException(Throwable $e) { @@ -185,6 +191,6 @@ protected function handleException(Throwable $e) } else if ($this->dieOnError) { Mage::printException($e); } - throw $e; + return $e; } }