Skip to content

Fixed regression with "default" being treated as proxy #448

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
Apr 24, 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
7 changes: 3 additions & 4 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,24 +398,23 @@ private function addProxyClientSection(ArrayNodeDefinition $rootNode)

->booleanNode('noop')->end()
->end()

->validate()
->always()
->then(function ($config) {
foreach ($config as $proxyName => $proxyConfig) {
$serversConfigured = isset($proxyConfig['http']) && isset($proxyConfig['http']['servers']) && \is_array($proxyConfig['http']['servers']);

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

return $config;
}

if ('symfony' === $proxyName) {
if (!$serversConfigured && false === $proxyConfig['use_kernel_dispatcher']) {
throw new \InvalidArgumentException(sprintf('Either configure the "http.servers" section or enable "use_kernel_dispatcher" the proxy "%s"', $proxyName));
throw new \InvalidArgumentException(sprintf('Either configure the "http.servers" section or enable "use_kernel_dispatcher" the proxy "%s"', $proxyName));
}
}
}
Expand Down
16 changes: 15 additions & 1 deletion tests/Unit/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,21 @@ public function testEmptyServerConfigurationIsNotAllowed()
];

$configuration = new Configuration(false);
$configuration = (new Processor())->processConfiguration($configuration, ['fos_http_cache' => $params]);
(new Processor())->processConfiguration($configuration, ['fos_http_cache' => $params]);
}

public function testDefaultIsNotConsideredAsServerConfig()
{
$params = $this->getEmptyConfig();
$params['proxy_client'] = [
'default' => 'varnish',
];

$configuration = new Configuration(false);
(new Processor())->processConfiguration($configuration, ['fos_http_cache' => $params]);

// Should not throw InvalidConfigurationException because no "http.servers" was configured
$this->addToAssertionCount(1);
}

public function testSupportsNoop()
Expand Down