10000 bug #59188 [HttpClient] Fix `reset()` not called on decorated clients… · symfony/framework-bundle@86f4863 · GitHub
[go: up one dir, main page]

Skip to content

Commit 86f4863

Browse files
committed
bug #59188 [HttpClient] Fix reset() not called on decorated clients (HypeMC)
This PR was merged into the 6.4 branch. Discussion ---------- [HttpClient] Fix `reset()` not called on decorated clients | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - | License | MIT This was broken in #49513 for the main HTTP client and, as far as I can tell, never worked for scoped clients. The problem is that some decorator clients, like the `ThrottlingHttpClient`, have their own `reset()` method, which never gets called when using the `services_resetter` service. Scoped clients don't decorate the main one but instead use it as a dependency. Commits ------- 8f5f98a5631 [HttpClient] Fix reset not called on decorated clients
2 parents 17d8ae2 + bfd1cf7 commit 86f4863

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2567,11 +2567,13 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
25672567
->setFactory([ScopingHttpClient::class, 'forBaseUri'])
25682568
->setArguments([new Reference('http_client.transport'), $baseUri, $scopeConfig])
25692569
->addTag('http_client.client')
2570+
->addTag('kernel.reset', ['method' => 'reset', 'on_invalid' => 'ignore'])
25702571
;
25712572
} else {
25722573
$container->register($name, ScopingHttpClient::class)
25732574
->setArguments([new Reference('http_client.transport'), [$scope => $scopeConfig], $scope])
25742575
->addTag('http_client.client')
2576+
->addTag('kernel.reset', ['method' => 'reset', 'on_invalid' => 'ignore'])
25752577
;
25762578
}
25772579

Resources/config/http_client.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
->factory('current')
4040
->args([[service('http_client.transport')]])
4141
->tag('http_client.client')
42+
->tag('kernel.reset', ['method' => 'reset', 'on_invalid' => 'ignore'])
4243

4344
->alias(HttpClientInterface::class, 'http_client')
4445

Tests/DependencyInjection/FrameworkExtensionTestCase.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1976,8 +1976,12 @@ public function testHttpClientDefaultOptions()
19761976
];
19771977
$this->assertSame([$defaultOptions, 4], $container->getDefinition('http_client.transport')->getArguments());
19781978

1979+
$this->assertTrue($container->getDefinition('http_client')->hasTag('kernel.reset'));
1980+
19791981
$this->assertTrue($container->hasDefinition('foo'), 'should have the "foo" service.');
1980-
$this->assertSame(ScopingHttpClient::class, $container->getDefinition('foo')->getClass());
1982+
$definition = $container->getDefinition('foo');
1983+
$this->assertSame(ScopingHttpClient::class, $definition->getClass());
1984+
$this->assertTrue($definition->hasTag('kernel.reset'));
19811985
}
19821986

19831987
public function testScopedHttpClientWithoutQueryOption()

0 commit comments

Comments
 (0)
0