Skip to content

Commit 13e97da

Browse files
committed
bug symfony#22535 [FrameworkBundle] Do not extend @Final SessionListener internally (chalasr)
This PR was merged into the 3.3-dev branch. Discussion ---------- [FrameworkBundle] Do not extend @Final SessionListener internally | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Revert the deprecated SessionListener class body instead of extending the new one which is `@final`, avoiding the following deprecations from the debug class loader: > User Deprecated: The Symfony\Bundle\FrameworkBundle\EventListener\SessionListener class is deprecated since version 3.3 and will be removed in 4.0. Use Symfony\Component\HttpKernel\EventListener\SessionListener instead. > User Deprecated: The Symfony\Component\HttpKernel\EventListener\SessionListener class is considered final since version 3.3. It may change without further notice as of its next major version. You should not extend it from Symfony\Bundle\FrameworkBundle\EventListener\SessionListener. spotted in symfony#22533 Commits ------- cf61102 Do not extend @Final SessionListener internally
2 parents 8701cae + cf61102 commit 13e97da

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/Symfony/Bundle/FrameworkBundle/EventListener/SessionListener.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,33 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\EventListener;
1313

14-
use Symfony\Component\HttpKernel\EventListener\SessionListener as BaseSessionListener;
14+
use Symfony\Component\DependencyInjection\ContainerInterface;
15+
use Symfony\Component\HttpKernel\EventListener\AbstractSessionListener;
1516

16-
@trigger_error(sprintf('The %s class is deprecated since version 3.3 and will be removed in 4.0. Use %s instead.', SessionListener::class, BaseSessionListener::class), E_USER_DEPRECATED);
17+
@trigger_error(sprintf('The %s class is deprecated since version 3.3 and will be removed in 4.0. Use Symfony\Component\HttpKernel\EventListener\SessionListener instead.', SessionListener::class), E_USER_DEPRECATED);
1718

1819
/**
1920
* Sets the session in the request.
2021
*
2122
* @author Fabien Potencier <[email protected]>
2223
*
23-
* @deprecated since version 3.3, to be removed in 4.0. Use {@link BaseSessionListener} instead
24+
* @deprecated since version 3.3, to be removed in 4.0. Use Symfony\Component\HttpKernel\EventListener\SessionListener instead
2425
*/
25-
class SessionListener extends BaseSessionListener
26+
class SessionListener extends AbstractSessionListener
2627
{
28+
private $container;
29+
30+
public function __construct(ContainerInterface $container)
31+
{
32+
$this->container = $container;
33+
}
34+
35+
protected function getSession()
36+
{
37+
if (!$this->container->has('session')) {
38+
return;
39+
}
40+
41+
return $this->container->get('session');
42+
}
2743
}

0 commit comments

Comments
 (0)