File tree Expand file tree Collapse file tree 7 files changed +41
-1
lines changed
Security/Tests/Http/Firewall Expand file tree Collapse file tree 7 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -518,7 +518,7 @@ public function hasPreviousSession()
518
518
*/
519
519
public function hasSession ()
520
520
{
521
- return null !== $ this ->session ;
521
+ return null !== $ this ->session && $ this -> session -> isStarted () ;
522
522
}
523
523
524
524
/**
Original file line number Diff line number Diff line change @@ -130,6 +130,14 @@ public function clear()
130
130
$ this ->storage ->getBag ($ this ->attributeName )->clear ();
131
131
}
132
132
133
+ /**
134
+ * {@inheritdoc}
135
+ */
136
+ public function isStarted ()
137
+ {
138
+ return $ this ->storage ->isStarted ();
139
+ }
140
+
133
141
/**
134
142
* Returns an iterator for attributes.
135
143
*
Original file line number Diff line number Diff line change @@ -174,6 +174,15 @@ function remove($name);
174
174
*/
175
175
function clear ();
176
176
177
+ /**
178
+ * Check if a session was started
179
+ *
180
+ * @api
181
+ *
182
+ * @return boolean
183
+ */
184
+ public function isStarted ();
185
+
177
186
/**
178
187
* Registers a SessionBagInterface with the session.
179
188
*
Original file line number Diff line number Diff line change @@ -199,6 +199,16 @@ public function getBag($name)
199
199
return $ this ->bags [$ name ];
200
200
}
201
201
202
+ /**
203
+ * Check if the session was started or not
204
+ *
205
+ * @return boolean
206
+ */
207
+ public function isStarted ()
208
+ {
209
+ return $ this ->started ;
210
+ }
211
+
202
212
/**
203
213
* Sets the MetadataBag.
204
214
*
Original file line number Diff line number Diff line change @@ -289,6 +289,16 @@ public function getMetadataBag()
289
289
return $ this ->metadataBag ;
290
290
}
291
291
292
+ /**
293
+ * Check if the session was started or not
294
+ *
295
+ * @return boolean
296
+ */
297
+ public function isStarted ()
298
+ {
299
+ return $ this ->started ;
300
+ }
301
+
292
302
/**
293
303
* Sets session.* ini variables.
294
304
*
Original file line number Diff line number Diff line change @@ -884,6 +884,7 @@ public function testHasSession()
884
884
885
885
$ this ->assertFalse ($ request ->hasSession ());
886
886
$ request ->setSession (new Session (new MockArraySessionStorage ()));
887
+ $ request ->getSession ()->start ();
887
888
$ this ->assertTrue ($ request ->hasSession ());
888
889
}
889
890
@@ -895,6 +896,7 @@ public function testHasPreviousSession()
895
896
$ request ->cookies ->set ('MOCKSESSID ' , 'foo ' );
896
897
$ this ->assertFalse ($ request ->hasPreviousSession ());
897
898
$ request ->setSession (new Session (new MockArraySessionStorage ()));
899
+ $ request ->getSession ()->start ();
898
900
$ this ->assertTrue ($ request ->hasPreviousSession ());
899
901
}
900
902
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ public function testOnKernelResponseWillRemoveSession()
85
85
protected function runSessionOnKernelResponse ($ newToken , $ original = null )
86
86
{
87
87
$ session = new Session (new MockArraySessionStorage ());
88
+ $ session ->start ();
88
89
89
90
if ($ original !== null ) {
90
91
$ session ->set ('_security_session ' , $ original );
You can’t perform that action at this time.
0 commit comments