diff --git a/src/Symfony/Component/HttpFoundation/Session/Session.php b/src/Symfony/Component/HttpFoundation/Session/Session.php index 0c40c1c32f89..6a13bee8552f 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Session.php +++ b/src/Symfony/Component/HttpFoundation/Session/Session.php @@ -256,7 +256,11 @@ public function getFlashes() $return = array(); if ($all) { foreach ($all as $name => $array) { - $return[$name] = reset($array); + if (is_numeric(key($array))) { + $return[$name] = reset($array); + } else { + $return[$name] = $array; + } } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php index bd45b2fbe6f4..2f2b26fb3ea2 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php @@ -183,6 +183,21 @@ public function testGetSetFlashes() $this->assertEquals(array('notice' => 'foo'), $this->session->getFlashes()); } + public function testGetFlashesWithArray() + { + $array = array('notice' => 'hello', 'error' => 'none'); + $this->assertEquals(array(), $this->session->getFlashes()); + $this->session->setFlash('foo', $array); + $this->assertEquals(array('foo' => $array), $this->session->getFlashes()); + $this->assertEquals(array(), $this->session->getFlashes()); + + $array = array('hello', 'foo'); + $this->assertEquals(array(), $this->session->getFlashes()); + $this->session->setFlash('foo', $array); + $this->assertEquals(array('foo' => 'hello'), $this->session->getFlashes()); + $this->assertEquals(array(), $this->session->getFlashes()); + } + public function testGetSetFlash() { $this->assertNull($this->session->getFlash('notice'));