Skip to content

Commit 9d7d260

Browse files
authored
Merge pull request #448 from Toflar/fix-regression
Fixed regression with "default" being treated as proxy
2 parents 01b6add + 4753d08 commit 9d7d260

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/DependencyInjection/Configuration.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,24 +398,23 @@ private function addProxyClientSection(ArrayNodeDefinition $rootNode)
398398

399399
->booleanNode('noop')->end()
400400
->end()
401-
402401
->validate()
403402
->always()
404403
->then(function ($config) {
405404
foreach ($config as $proxyName => $proxyConfig) {
406405
$serversConfigured = isset($proxyConfig['http']) && isset($proxyConfig['http']['servers']) && \is_array($proxyConfig['http']['servers']);
407406

408-
if (!\in_array($proxyName, ['noop', 'symfony'])) {
407+
if (!\in_array($proxyName, ['noop', 'default', 'symfony'])) {
409408
if (!$serversConfigured) {
410-
throw new \InvalidArgumentException(sprintf('The "http.servers" section must be defined for the proxy "%s"', $proxyName));
409+
throw new \InvalidArgumentException(sprintf('The "http.servers" section must be defined for the proxy "%s"', $proxyName));
411410
}
412411

413412
return $config;
414413
}
415414

416415
if ('symfony' === $proxyName) {
417416
if (!$serversConfigured && false === $proxyConfig['use_kernel_dispatcher']) {
418-
throw new \InvalidArgumentException(sprintf('Either configure the "http.servers" section or enable "use_kernel_dispatcher" the proxy "%s"', $proxyName));
417+
throw new \InvalidArgumentException(sprintf('Either configure the "http.servers" section or enable "use_kernel_dispatcher" the proxy "%s"', $proxyName));
419418
}
420419
}
421420
}

tests/Unit/DependencyInjection/ConfigurationTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,21 @@ public function testEmptyServerConfigurationIsNotAllowed()
306306
];
307307

308308
$configuration = new Configuration(false);
309-
$configuration = (new Processor())->processConfiguration($configuration, ['fos_http_cache' => $params]);
309+
(new Processor())->processConfiguration($configuration, ['fos_http_cache' => $params]);
310+
}
311+
312+
public function testDefaultIsNotConsideredAsServerConfig()
313+
{
314+
$params = $this->getEmptyConfig();
315+
$params['proxy_client'] = [
316+
'default' => 'varnish',
317+
];
318+
319+
$configuration = new Configuration(false);
320+
(new Processor())->processConfiguration($configuration, ['fos_http_cache' => $params]);
321+
322+
// Should not throw InvalidConfigurationException because no "http.servers" was configured
323+
$this->addToAssertionCount(1);
310324
}
311325

312326
public function testSupportsNoop()

0 commit comments

Comments
 (0)