Skip to content

Commit bc6ffee

Browse files
committed
[HttpFoundation] fixed flash management
1 parent a1fcbf4 commit bc6ffee

File tree

2 files changed

+171
-196
lines changed

2 files changed

+171
-196
lines changed

src/Symfony/Component/HttpFoundation/Session.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ public function setFlashes($values)
223223
}
224224

225225
$this->attributes['_flash'] = $values;
226+
$this->oldFlashes = array();
226227
}
227228

228229
public function getFlash($name, $default = null)
@@ -242,27 +243,42 @@ public function setFlash($name, $value)
242243

243244
public function hasFlash($name)
244245
{
246+
if (false === $this->started) {
247+
$this->start();
248+
}
249+
245250
return array_key_exists($name, $this->attributes['_flash']);
246251
}
247252

248253
public function removeFlash($name)
249254
{
255+
if (false === $this->started) {
256+
$this->start();
257+
}
258+
250259
unset($this->attributes['_flash'][$name]);
251260
}
252261

253262
public function clearFlashes()
254263
{
264+
if (false === $this->started) {
265+
$this->start();
266+
}
267+
255268
$this->attributes['_flash'] = array();
269+
$this->oldFlashes = array();
256270
}
257271

258272
public function save()
259273
{
260-
if (true === $this->started) {
261-
if (isset($this->attributes['_flash'])) {
262-
$this->attributes['_flash'] = array_diff_key($this->attributes['_flash'], $this->oldFlashes);
263-
}
264-
$this->storage->write('_symfony2', $this->attributes);
274+
if (false === $this->started) {
275+
$this->start();
276+
}
277+
278+
if (isset($this->attributes['_flash'])) {
279+
$this->attributes['_flash'] = array_diff_key($this->attributes['_flash'], $this->oldFlashes);
265280
}
281+
$this->storage->write('_symfony2', $this->attributes);
266282
}
267283

268284
public function __destruct()

0 commit comments

Comments
 (0)