Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a3bceff

Browse filesBrowse files
committed
bug #45479 [HttpKernel] Reset services between requests performed by KernelBrowser (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [HttpKernel] Reset services between requests performed by KernelBrowser | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #40965 | License | MIT | Doc PR | - This fixes memory leaks caused by the container not being reset between requests made via `KernelBrowser` when *not* calling `KernelBrowser::disableReboot();`. There is already a call to `$container->reset()` in `KernelTestCase::ensureKernelShutdown()`, but `KernelBrowser` creates new container instances for each requests, and those containers were never reset. Commits ------- 592a00a [HttpKernel] Reset services between requests performed by KernelBrowser
2 parents 57a078b + 592a00a commit a3bceff
Copy full SHA for a3bceff

File tree

Expand file treeCollapse file tree

2 files changed

+7
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-1
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Client.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Client.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\HttpKernel\HttpKernelBrowser;
2020
use Symfony\Component\HttpKernel\KernelInterface;
2121
use Symfony\Component\HttpKernel\Profiler\Profile as HttpProfile;
22+
use Symfony\Contracts\Service\ResetInterface;
2223

2324
/**
2425
* Client simulates a browser and makes requests to a Kernel object.
@@ -116,7 +117,12 @@ protected function doRequest($request)
116117
// avoid shutting down the Kernel if no request has been performed yet
117118
// WebTestCase::createClient() boots the Kernel but do not handle a request
118119
if ($this->hasPerformedRequest && $this->reboot) {
120+
$container = $this->kernel->getContainer();
119121
$this->kernel->shutdown();
122+
123+
if ($container instanceof ResetInterface) {
124+
$container->reset();
125+
}
120126
} else {
121127
$this->hasPerformedRequest = true;
122128
}

‎src/Symfony/Bundle/FrameworkBundle/Tests/KernelBrowserTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/KernelBrowserTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function testEnableRebootKernel()
5454
private function getKernelMock()
5555
{
5656
$mock = $this->getMockBuilder($this->getKernelClass())
57-
->setMethods(['shutdown', 'boot', 'handle'])
57+
->setMethods(['shutdown', 'boot', 'handle', 'getContainer'])
5858
->disableOriginalConstructor()
5959
->getMock();
6060

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.