File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ private function getSessionId(): ?string
4949 } else {
5050 $ sessionId = $ _COOKIE [$ sessionName ] ?? null ;
5151 }
52- return is_string ($ sessionId ) ? $ sessionId : null ;
52+ return is_string ($ sessionId ) && $ sessionId !== '' ? $ sessionId : null ;
5353 }
5454
5555
Original file line number Diff line number Diff line change @@ -23,11 +23,7 @@ class PhpInfoTest extends TestCase
2323 protected function setUp (): void
2424 {
2525 $ _SERVER ['HTTP_WALDO_FRED ' ] = self ::WALDO_1337 ;
26- $ _SERVER ['HTTP_COOKIE ' ] = 'PHPSESSID= ' . urlencode (self ::SESSION_ID );
27- $ _COOKIE ['PHPSESSID ' ] = self ::SESSION_ID ;
28-
29- session_set_save_handler (new TestSessionHandler (self ::SESSION_ID ));
30- session_start ();
26+ $ this ->sessionStart (self ::SESSION_ID );
3127 }
3228
3329
@@ -135,6 +131,25 @@ class PhpInfoTest extends TestCase
135131 Assert::contains ('🍕 ' , $ html );
136132 }
137133
134+
135+ public function testGetHtmlEmptySessionCookie (): void
136+ {
137+ session_destroy ();
138+ $ this ->sessionStart ('' );
139+ Assert::noError (function (): void {
140+ (new PhpInfo ())->getHtml ();
141+ });
142+ }
143+
144+
145+ private function sessionStart (string $ sessionId ): void
146+ {
147+ $ _SERVER ['HTTP_COOKIE ' ] = 'PHPSESSID= ' . urlencode ($ sessionId );
148+ $ _COOKIE ['PHPSESSID ' ] = $ sessionId ;
149+ session_set_save_handler (new TestSessionHandler ($ sessionId ));
150+ session_start ();
151+ }
152+
138153}
139154
140155(new PhpInfoTest ())->run ();
You can’t perform that action at this time.
0 commit comments