From db5fd2d983ffe0e44706fe20d2e820f2783aa653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20G=C3=B6r=C3=9F?= Date: Wed, 29 May 2024 11:02:02 +0200 Subject: [PATCH 1/2] fix: replace array merge with array replace on session store --- src/Illuminate/Session/Store.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Session/Store.php b/src/Illuminate/Session/Store.php index 5e07f5f34bf8..b0fd2967a5cd 100755 --- a/src/Illuminate/Session/Store.php +++ b/src/Illuminate/Session/Store.php @@ -98,7 +98,7 @@ public function start() */ protected function loadSession() { - $this->attributes = array_merge($this->attributes, $this->readFromHandler()); + $this->attributes = array_replace($this->attributes, $this->readFromHandler()); $this->marshalErrorBag(); } From ef4c2acb57b3827f06af51a42945dc263075925d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20G=C3=B6r=C3=9F?= Date: Wed, 29 May 2024 11:02:16 +0200 Subject: [PATCH 2/2] test: add only integer test case to load session from handler --- tests/Session/SessionStoreTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/Session/SessionStoreTest.php b/tests/Session/SessionStoreTest.php index 9f2e89a98ece..f4f4fb8e5fbb 100644 --- a/tests/Session/SessionStoreTest.php +++ b/tests/Session/SessionStoreTest.php @@ -24,12 +24,14 @@ protected function tearDown(): void public function testSessionIsLoadedFromHandler() { $session = $this->getSession(); - $session->getHandler()->shouldReceive('read')->once()->with($this->getSessionId())->andReturn(serialize(['foo' => 'bar', 'bagged' => ['name' => 'taylor']])); + $session->getHandler()->shouldReceive('read')->once()->with($this->getSessionId())->andReturn(serialize(['foo' => 'bar', 'bagged' => ['name' => 'taylor'], '123' => 'bax'])); $session->start(); $this->assertSame('bar', $session->get('foo')); + $this->assertSame('bax', $session->get('123')); $this->assertSame('baz', $session->get('bar', 'baz')); $this->assertTrue($session->has('foo')); + $this->assertTrue($session->has('123')); $this->assertFalse($session->has('bar')); $this->assertTrue($session->isStarted());