Skip to content

Add SessionListener::onFinishRequest method to work with Symfony 3.4.12 #472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

1.3.16
------

* Adjust session_listener to work with Symfony 3.4.12 (https://github.com/symfony/symfony/pull/27467).

1.3.15
------

Expand Down
7 changes: 7 additions & 0 deletions EventListener/SessionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\EventListener\SessionListener as BaseSessionListener;

Expand Down Expand Up @@ -78,6 +79,12 @@ public function onKernelResponse(FilterResponseEvent $event)
// noop, see class description
}

public function onFinishRequest(FinishRequestEvent $event)
{
// this hook has been added in symfony 3.4.12 - older versions of the listener do not register for it
$this->inner->onFinishRequest($event);
}

public static function getSubscribedEvents()
{
return BaseSessionListener::getSubscribedEvents();
Expand Down
26 changes: 26 additions & 0 deletions Tests/Unit/EventListener/SessionListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,32 @@ public function testOnKernelRequestRemainsUntouched()
$listener->onKernelRequest($event);
}

public function testOnFinishRequestRemainsUntouched()
{
if (!method_exists('Symfony\Component\HttpKernel\EventListener\SessionListener', 'onFinishRequest')) {
$this->markTestSkipped('Method onFinishRequest does not exist on Symfony\Component\HttpKernel\EventListener\SessionListener');
}

$event = $this
->getMockBuilder('Symfony\Component\HttpKernel\Event\FinishRequestEvent')
->disableOriginalConstructor()
->getMock();

$inner = $this
->getMockBuilder('Symfony\Component\HttpKernel\EventListener\SessionListener')
->disableOriginalConstructor()
->getMock();

$inner
->expects($this->once())
->method('onFinishRequest')
->with($event)
;

$listener = $this->getListener($inner);
$listener->onFinishRequest($event);
}

/**
* @dataProvider onKernelResponseProvider
*/
Expand Down