Skip to content

Commit 73e2000

Browse files
warslettfabpot
authored andcommitted
[FrameworkBundle] Deprecate flashbag and attributebag services
1 parent adc073e commit 73e2000

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ CHANGELOG
1717
* Added `debug:container --deprecations` option to see compile-time deprecations.
1818
* Made `BrowserKitAssertionsTrait` report the original error message in case of a failure
1919
* Added ability for `config:dump-reference` and `debug:config` to dump and debug kernel container extension configuration.
20+
* Deprecated `session.attribute_bag` service and `session.flash_bag` service.
2021

2122
5.0.0
2223
-----

Resources/config/session.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@
4343

4444
<service id="session.flash_bag" class="Symfony\Component\HttpFoundation\Session\Flash\FlashBag">
4545
<factory service="session" method="getFlashBag" />
46+
<deprecated package="symfony/framework-bundle" version="5.1">The "%service_id%" service is deprecated, use "$session->getFlashBag()" instead.</deprecated>
4647
</service>
4748
<service id="Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface" alias="session.flash_bag" />
4849

4950
<service id="session.attribute_bag" class="Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag">
5051
<factory service="session" method="getAttributeBag" />
52+
<deprecated package="symfony/framework-bundle" version="5.1">The "%service_id%" service is deprecated, use "$session->getAttributeBag()" instead.</deprecated>
5153
</service>
5254

5355
<service id="session.storage.mock_file" class="Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage">

Tests/Functional/SessionTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
1313

14+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
15+
1416
class SessionTest extends AbstractWebTestCase
1517
{
18+
use ExpectDeprecationTrait;
19+
1620
/**
1721
* Tests session attributes persist.
1822
*
@@ -72,10 +76,13 @@ public function testFlash($config, $insulate)
7276
/**
7377
* Tests flash messages work when flashbag service is injected to the constructor.
7478
*
79+
* @group legacy
7580
* @dataProvider getConfigs
7681
*/
7782
public function testFlashOnInjectedFlashbag($config, $insulate)
7883
{
84+
$this->expectDeprecation('Since symfony/framework-bundle 5.1: The "session.flash_bag" service is deprecated, use "$session->getFlashBag()" instead.');
85+
7986
$client = $this->createClient(['test_case' => 'Session', 'root_config' => $config]);
8087
if ($insulate) {
8188
$client->insulate();

0 commit comments

Comments
 (0)