-
Notifications
You must be signed in to change notification settings - Fork 83
update to use 2.0 of FOSHttpCache #235
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,33 @@ Changelog | |
2.0.0 (unreleased) | ||
------------------ | ||
|
||
* [User Context] Added an option always_vary_on_context_hash to make it | ||
possible to disable automatically setting the vary headers for the user | ||
* [Proxy Client Configuration] The configuration for the proxy client has been | ||
adjusted. Proxy servers are now configured under `http` and `servers` must be | ||
a list - a comma separated string of server IPs is no longer supported. | ||
|
||
* [User Context] Added an option always_vary_on_context_hash to make it | ||
possible to disable automatically setting the vary headers for the user | ||
hash. | ||
|
||
* [Event Listeners] Renamed the event listener classes to XxxLlistener | ||
* [Event Listeners] Renamed the event listener classes to XxxLlistener. | ||
|
||
* Updated the version of FOSHttpCache to 2.*. See [FOSHttpCache changelog] | ||
(https://github.com/FriendsOfSymfony/FOSHttpCache/blob/master/CHANGELOG.md). | ||
Most important, there is no more hard coupling on Guzzle HTTP client. We now | ||
use the HTTPlug HTTP client abstraction. Your composer.json now needs to | ||
specify which HTTP client to install, see [installation instructions] | ||
(http://foshttpcachebundle.readthedocs.org/en/stable/installation.html) | ||
|
||
* [Tags] The TagHandler has been split. Invalidating tags happens through the | ||
CacheManager (if you use annotations for tag invalidation, you don't need to | ||
change anything). Recording tags and writing them into the responses is done | ||
through the SymfonyResponseTagger now. | ||
|
||
* [Test] Dropped the proxy client services as they where not used anywhere. The | ||
services `fos_http_cache.test.client.varnish` and `fos_http_cache.test.client.nginx` | ||
no longer exist. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ddeboer can you agree with this? i feel that with httplug and discovery, its easy enough to do this now on your own in tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed! |
||
|
||
* Deprecated methods have been removed. | ||
|
||
1.3.7 | ||
----- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
|
||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; | ||
use Symfony\Component\Config\Definition\Builder\NodeBuilder; | ||
use Symfony\Component\Config\Definition\Builder\NodeDefinition; | ||
use Symfony\Component\Config\Definition\Builder\TreeBuilder; | ||
use Symfony\Component\Config\Definition\ConfigurationInterface; | ||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; | ||
|
@@ -93,36 +94,6 @@ public function getConfigTreeBuilder() | |
throw new InvalidConfigurationException('You need to configure a proxy_client to get the cache_manager needed for invalidation handling.'); | ||
}) | ||
->end() | ||
->validate() | ||
->ifTrue(function ($v) { | ||
return isset($v['test']) | ||
&& $v['test']['client']['varnish']['enabled'] | ||
&& !isset($v['proxy_client']['varnish']); | ||
}) | ||
->then(function ($v) { | ||
if ('auto' === $v['test']['client']['varnish']['enabled']) { | ||
$v['test']['client']['varnish']['enabled'] = false; | ||
|
||
return $v; | ||
} | ||
throw new InvalidConfigurationException('You need to configure the Varnish proxy_client to use the Varnish test client'); | ||
}) | ||
->end() | ||
->validate() | ||
->ifTrue(function ($v) { | ||
if (isset($v['test'])) { | ||
return $v['test']['client']['nginx']['enabled'] && !isset($v['proxy_client']['nginx']); | ||
} | ||
}) | ||
->then(function ($v) { | ||
if ('auto' === $v['test']['client']['nginx']['enabled']) { | ||
$v['test']['client']['nginx']['enabled'] = false; | ||
|
||
return $v; | ||
} | ||
throw new InvalidConfigurationException('You need to configure the Nginx proxy_client to use the Nginx test client'); | ||
}) | ||
->end() | ||
->validate() | ||
->ifTrue( | ||
function ($v) { | ||
|
@@ -314,81 +285,27 @@ private function addProxyClientSection(ArrayNodeDefinition $rootNode) | |
->children() | ||
->enumNode('default') | ||
->values(array('varnish', 'nginx', 'symfony')) | ||
->info('If you configure more than one proxy client, specify which client is the default.') | ||
->info('If you configure more than one proxy client, you need to specify which client is the default.') | ||
->end() | ||
->arrayNode('varnish') | ||
->fixXmlConfig('server') | ||
->children() | ||
->arrayNode('servers') | ||
->beforeNormalization()->ifString()->then(function ($v) { | ||
return preg_split('/\s*,\s*/', $v); | ||
})->end() | ||
->useAttributeAsKey('name') | ||
->isRequired() | ||
->requiresAtLeastOneElement() | ||
->prototype('scalar')->end() | ||
->info('Addresses of the hosts Varnish is running on. May be hostname or ip, and with :port if not the default port 80.') | ||
->end() | ||
->scalarNode('base_url') | ||
->defaultNull() | ||
->info('Default host name and optional path for path based invalidation.') | ||
->end() | ||
->scalarNode('guzzle_client') | ||
->defaultNull() | ||
->info('Guzzle service to use for customizing the requests.') | ||
->end() | ||
->append($this->getHttpDispatcherNode()) | ||
->end() | ||
->end() | ||
|
||
->arrayNode('nginx') | ||
->fixXmlConfig('server') | ||
->children() | ||
->arrayNode('servers') | ||
->beforeNormalization()->ifString()->then(function ($v) { | ||
return preg_split('/\s*,\s*/', $v); | ||
})->end() | ||
->useAttributeAsKey('name') | ||
->isRequired() | ||
->requiresAtLeastOneElement() | ||
->prototype('scalar')->end() | ||
->info('Addresses of the hosts Nginx is running on. May be hostname or ip, and with :port if not the default port 80.') | ||
->end() | ||
->scalarNode('base_url') | ||
->defaultNull() | ||
->info('Default host name and optional path for path based invalidation.') | ||
->end() | ||
->scalarNode('guzzle_client') | ||
->defaultNull() | ||
->info('Guzzle service to use for customizing the requests.') | ||
->end() | ||
->scalarNode('purge_location') | ||
->defaultValue('') | ||
->defaultValue(false) | ||
->info('Path to trigger the purge on Nginx for different location purge.') | ||
->end() | ||
->append($this->getHttpDispatcherNode()) | ||
->end() | ||
->end() | ||
|
||
->arrayNode('symfony') | ||
->fixXmlConfig('server') | ||
->children() | ||
->arrayNode('servers') | ||
->beforeNormalization()->ifString()->then(function ($v) { | ||
return preg_split('/\s*,\s*/', $v); | ||
})->end() | ||
->useAttributeAsKey('name') | ||
->isRequired() | ||
->requiresAtLeastOneElement() | ||
->prototype('scalar')->end() | ||
->info('Addresses of the hosts Symfony HttpCache is running on. May be hostname or ip, and with :port if not the default port 80.') | ||
->end() | ||
->scalarNode('base_url') | ||
->defaultNull() | ||
->info('Default host name and optional path for path based invalidation.') | ||
->end() | ||
->scalarNode('guzzle_client') | ||
->defaultNull() | ||
->info('Guzzle service to use for customizing the requests.') | ||
->end() | ||
->append($this->getHttpDispatcherNode()) | ||
->end() | ||
->end() | ||
|
||
|
@@ -397,6 +314,41 @@ private function addProxyClientSection(ArrayNodeDefinition $rootNode) | |
->end(); | ||
} | ||
|
||
/** | ||
* Get the configuration node for a HTTP dispatcher in a proxy client. | ||
* | ||
* @return NodeDefinition | ||
*/ | ||
private function getHttpDispatcherNode() | ||
{ | ||
$treeBuilder = new TreeBuilder(); | ||
$node = $treeBuilder->root('http'); | ||
|
||
$node | ||
->fixXmlConfig('server') | ||
->isRequired() | ||
->children() | ||
->arrayNode('servers') | ||
->info('Addresses of the hosts the caching proxy is running on. May be hostname or ip, and with :port if not the default port 80.') | ||
->useAttributeAsKey('name') | ||
->isRequired() | ||
->requiresAtLeastOneElement() | ||
->prototype('scalar')->end() | ||
->end() | ||
->scalarNode('base_url') | ||
->defaultNull() | ||
->info('Default host name and optional path for path based invalidation.') | ||
->end() | ||
->scalarNode('http_client') | ||
->defaultNull() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't need any reference to the httplug-bundle. by default, we pass no client to HttpDispatcher, which will prompt that to do a discovery. if discovery is not desired, a client can be configured. |
||
->info('Httplug async client service name to use for sending the requests.') | ||
->end() | ||
->end() | ||
; | ||
|
||
return $node; | ||
} | ||
|
||
private function addTestSection(ArrayNodeDefinition $rootNode) | ||
{ | ||
$rootNode | ||
|
@@ -432,37 +384,6 @@ private function addTestSection(ArrayNodeDefinition $rootNode) | |
->end() | ||
->end() | ||
->end() | ||
->arrayNode('client') | ||
->addDefaultsIfNotSet() | ||
->children() | ||
->enumNode('default') | ||
->values(array('varnish', 'nginx')) | ||
->info('If you configure more than one proxy client, specify which client is the default.') | ||
->end() | ||
->arrayNode('varnish') | ||
->addDefaultsIfNotSet() | ||
->canBeEnabled() | ||
->children() | ||
->enumNode('enabled') | ||
->values(array(true, false, 'auto')) | ||
->defaultValue('auto') | ||
->info('Whether to enable the Varnish test client.') | ||
->end() | ||
->end() | ||
->end() | ||
->arrayNode('nginx') | ||
->addDefaultsIfNotSet() | ||
->canBeEnabled() | ||
->children() | ||
->enumNode('enabled') | ||
->values(array(true, false, 'auto')) | ||
->defaultValue('auto') | ||
->info('Whether to enable the Nginx test client.') | ||
->end() | ||
->end() | ||
->end() | ||
->end() | ||
->end() | ||
->end() | ||
->end() | ||
->end(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jordi thinks we hit some hard to tell edge case: https://twitter.com/seldaek/status/805698883456270336
i comment this build out for now and try again when we released the library