Skip to content

Commit 536d851

Browse files
committed
Merge branch '5.4' into 6.4
* 5.4: Fix Twig deprecation notice [DependencyInjection] Fix issue between decorator and service locator index do not overwrite the host to request
2 parents 93e8814 + a2ad15c commit 536d851

File tree

5 files changed

+27
-6
lines changed

5 files changed

+27
-6
lines changed

src/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class TwigNodeProvider
2828
public static function getModule($content)
2929
{
3030
return new ModuleNode(
31-
new ConstantExpression($content, 0),
31+
new BodyNode([new ConstantExpression($content, 0)]),
3232
null,
3333
new ArrayExpression([], 0),
3434
new ArrayExpression([], 0),

src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ private function findAndSortTaggedServices(string|TaggedIteratorArgument $tagNam
8585
} elseif (null === $defaultIndex && $defaultPriorityMethod && $class) {
8686
$defaultIndex = PriorityTaggedServiceUtil::getDefault($container, $serviceId, $class, $defaultIndexMethod ?? 'getDefaultName', $tagName, $indexAttribute, $checkTaggedItem);
8787
}
88-
$index ??= $defaultIndex ??= $serviceId;
88+
$decorated = $definition->getTag('container.decorator')[0]['id'] ?? null;
89+
$index = $index ?? $defaultIndex ?? $defaultIndex = $decorated ?? $serviceId;
8990

9091
$services[] = [$priority, ++$i, $index, $serviceId, $class];
9192
}

src/Symfony/Component/DependencyInjection/Tests/Compiler/PriorityTaggedServiceTraitTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ public function testTheIndexedTagsByDefaultIndexMethod()
153153

154154
$container->register('service4', HelloInterface::class)->addTag('my_custom_tag');
155155

156+
$definition = $container->register('debug.service5', \stdClass::class)->addTag('my_custom_tag');
157+
$definition->addTag('container.decorator', ['id' => 'service5']);
158+
156159
$priorityTaggedServiceTraitImplementation = new PriorityTaggedServiceTraitImplementation();
157160

158161
$tag = new TaggedIteratorArgument('my_custom_tag', 'foo', 'getFooBar');
@@ -161,6 +164,7 @@ public function testTheIndexedTagsByDefaultIndexMethod()
161164
'service1' => new TypedReference('service1', FooTagClass::class),
162165
'10' => new TypedReference('service3', IntTagClass::class),
163166
'service4' => new TypedReference('service4', HelloInterface::class),
167+
'service5' => new TypedReference('debug.service5', \stdClass::class),
164168
];
165169
$services = $priorityTaggedServiceTraitImplementation->test($tag, $container);
166170
$this->assertSame(array_keys($expected), array_keys($services));

src/Symfony/Component/HttpClient/CurlHttpClient.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ public function request(string $method, string $url, array $options = []): Respo
188188
$multi->reset();
189189
}
190190

191-
foreach ($options['resolve'] as $host => $ip) {
192-
$resolve[] = null === $ip ? "-$host:$port" : "$host:$port:$ip";
193-
$multi->dnsCache->hostnames[$host] = $ip;
194-
$multi->dnsCache->removals["-$host:$port"] = "-$host:$port";
191+
foreach ($options['resolve'] as $resolveHost => $ip) {
192+
$resolve[] = null === $ip ? "-$resolveHost:$port" : "$resolveHost:$port:$ip";
193+
$multi->dnsCache->hostnames[$resolveHost] = $ip;
194+
$multi->dnsCache->removals["-$resolveHost:$port"] = "-$resolveHost:$port";
195195
}
196196

197197
$curlopts[\CURLOPT_RESOLVE] = $resolve;

src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,20 @@ public function testOverridingInternalAttributesUsingCurlOptions()
122122
],
123123
]);
124124
}
125+
126+
public function testKeepAuthorizationHeaderOnRedirectToSameHostWithConfiguredHostToIpAddressMapping()
127+
{
128+
$httpClient = $this->getHttpClient(__FUNCTION__);
129+
$response = $httpClient->request('POST', 'http://127.0.0.1:8057/301', [
130+
'headers' => [
131+
'Authorization' => 'Basic Zm9vOmJhcg==',
132+
],
133+
'resolve' => [
134+
'symfony.com' => '10.10.10.10',
135+
],
136+
]);
137+
138+
$this->assertSame(200, $response->getStatusCode());
139+
$this->assertSame('/302', $response->toArray()['REQUEST_URI'] ?? null);
140+
}
125141
}

0 commit comments

Comments
 (0)