Skip to content

Commit 552472b

Browse files
committed
Merge pull request #323 from FriendsOfSymfony/cleanup-travisscript
cleanup travis script and naming of varnish config
2 parents d7b79e0 + 66f64ef commit 552472b

23 files changed

+165
-156
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ install:
3030
before_script:
3131
# Install Varnish
3232
- |
33+
set -e
3334
if [ "$VARNISH_VERSION" = "5.0.0" ]; then
3435
wget https://repo.varnish-cache.org/pkg/${VARNISH_VERSION}/varnish_${VARNISH_VERSION}-1_amd64.deb
3536
sudo dpkg -i varnish_${VARNISH_VERSION}-1_amd64.deb
3637
sudo apt-get update -qq
3738
sudo apt-get -f install
3839
else
3940
curl http://repo.varnish-cache.org/debian/GPG-key.txt | sudo apt-key add -
40-
echo "deb http://repo.varnish-cache.org/ubuntu/ precise varnish-${VARNISH_VERSION}" | sudo tee -a /etc/apt/sources.list
41+
echo "deb https://repo.varnish-cache.org/ubuntu/ trusty varnish-${VARNISH_VERSION}" | sudo tee -a /etc/apt/sources.list
4142
sudo apt-get update -qq
4243
sudo apt-get install -qq varnish
4344
fi

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ See also the [GitHub releases page](https://github.com/FriendsOfSymfony/FOSHttpC
1616
* Added support and documentation for setting a custom TTL specifically for the
1717
caching proxy.
1818

19+
### Logging
20+
21+
* BC BREAK: Renamed the log event listener from Logsubscriber to LogListener.
22+
1923
### Tagging
2024

2125
* Abstracting tags by adding new `TagsInterface` for ProxyClients, as part of
@@ -29,7 +33,7 @@ See also the [GitHub releases page](https://github.com/FriendsOfSymfony/FOSHttpC
2933

3034
* Varnish configuration are now files that you can directly include from your
3135
.vcl and call custom functions to avoid copy-pasting VCL code.
32-
* Moved Varnish 4 and 5 configuration files from `resources/config/varnish-4/`
36+
* Moved Varnish 4 and 5 configuration files from `resources/config/varnish-4/`
3337
to `resources/config/varnish/`.
3438
* Changed default Varnish version to 5.
3539

@@ -40,7 +44,8 @@ See also the [GitHub releases page](https://github.com/FriendsOfSymfony/FOSHttpC
4044

4145
### Symfony HttpCache
4246

43-
* BC BREAK: Constructors for PurgeSubscriber and RefreshSubscriber now use an
47+
* BC BREAK: Renamed all event listeners to XxListener instead of XxSubscriber.
48+
* BC BREAK: Constructors for PurgeListener and RefreshListener now use an
4449
options array for customization.
4550

4651
### Testing

doc/_static/tabs.css

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ div.configuration-block ul.simple li.selected a {
2525
color: white;
2626
}
2727

28-
div.highlight-varnish3, div.highlight-varnish4 {
28+
div.highlight-varnish3, div.highlight-varnish {
2929
border: none !important;
3030
}
3131

@@ -55,10 +55,10 @@ div.highlight pre {
5555
color: white !important;
5656
}
5757

58-
div.highlight pre span.n,
59-
div.highlight pre span.na,
60-
div.highlight pre span.nb,
61-
div.highlight pre span.nc,
58+
div.highlight pre span.n,
59+
div.highlight pre span.na,
60+
div.highlight pre span.nb,
61+
div.highlight pre span.nc,
6262
div.highlight pre span.nf,
6363
div.highlight pre span.nx,
6464
div.highlight pre span.kn {
@@ -74,8 +74,8 @@ div.highlight pre span.k, div.highlight pre span.o {
7474
}
7575

7676
div.highlight pre span.mi,
77-
div.highlight pre span.s,
78-
div.highlight pre span.s1,
77+
div.highlight pre span.s,
78+
div.highlight pre span.s1,
7979
div.highlight pre span.s2,
8080
div.highlight pre span.sr {
8181
color: #56db3a;

doc/cache-invalidator.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ So, to catch exceptions::
224224
Logging errors
225225
~~~~~~~~~~~~~~
226226

227-
You can log any exceptions with the help of the ``LogSubscriber`` provided in
227+
You can log any exceptions with the help of the ``LogListener`` provided in
228228
this library. First construct a logger that implements
229229
``\Psr\Log\LoggerInterface``. For instance, when using Monolog_::
230230

@@ -233,12 +233,12 @@ this library. First construct a logger that implements
233233
$monolog = new Logger(...);
234234
$monolog->pushHandler(...);
235235

236-
Then add the logger as a subscriber to the cache invalidator::
236+
Then add the logger as a listener to the cache invalidator::
237237

238-
use FOS\HttpCache\EventListener\LogSubscriber;
238+
use FOS\HttpCache\EventListener\LogListener;
239239

240-
$subscriber = new LogSubscriber($monolog);
241-
$cacheInvalidator->getEventDispatcher()->addSubscriber($subscriber);
240+
$logListener = new LogListener($monolog);
241+
$cacheInvalidator->getEventDispatcher()->addSubscriber($logListener);
242242

243243
Now, if you flush the invalidator, errors will be logged::
244244

doc/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
lexers['php'] = PhpLexer(startinline=True, linenos=1)
1111
lexers['varnish3'] = CLexer()
12-
lexers['varnish4'] = CLexer()
12+
lexers['varnish'] = CLexer()
1313

1414
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
1515
if not on_rtd: # only import and set the theme if we're building docs locally
@@ -263,5 +263,5 @@ def setup(app):
263263

264264
config_block = {
265265
'varnish3': 'Varnish 3',
266-
'varnish4': 'Varnish 4 & 5'
266+
'varnish': 'Varnish 4 & 5'
267267
}

doc/symfony-cache-configuration.rst

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ trait ``FOS\HttpCache\SymfonyCache\EventDispatchingHttpCache``::
4040
use EventDispatchingHttpCache;
4141

4242
/**
43-
* Made public to allow event subscribers to do refresh operations.
43+
* Made public to allow event listeners to do refresh operations.
4444
*
4545
* {@inheritDoc}
4646
*/
@@ -86,14 +86,14 @@ the listeners you need there::
8686

8787
use FOS\HttpCache\SymfonyCache\DebugListener();
8888
use FOS\HttpCache\SymfonyCache\CustomTtlListener();
89-
use FOS\HttpCache\SymfonyCache\PurgeSubscriber;
90-
use FOS\HttpCache\SymfonyCache\RefreshSubscriber;
91-
use FOS\HttpCache\SymfonyCache\UserContextSubscriber;
89+
use FOS\HttpCache\SymfonyCache\PurgeListener;
90+
use FOS\HttpCache\SymfonyCache\RefreshListener;
91+
use FOS\HttpCache\SymfonyCache\UserContextListener;
9292

9393
// ...
9494

9595
/**
96-
* Overwrite constructor to register event subscribers for FOSHttpCache.
96+
* Overwrite constructor to register event listeners for FOSHttpCache.
9797
*/
9898
public function __construct(
9999
HttpKernelInterface $kernel,
@@ -104,9 +104,9 @@ the listeners you need there::
104104
parent::__construct($kernel, $store, $surrogate, $options);
105105

106106
$this->addSubscriber(new CustomTtlListener());
107-
$this->addSubscriber(new PurgeSubscriber());
108-
$this->addSubscriber(new RefreshSubscriber());
109-
$this->addSubscriber(new UserContextSubscriber());
107+
$this->addSubscriber(new PurgeListener());
108+
$this->addSubscriber(new RefreshListener());
109+
$this->addSubscriber(new UserContextListener());
110110
if (isset($options['debug']) && $options['debug']) {
111111
$this->addSubscriber(new DebugListener());
112112
}
@@ -120,7 +120,7 @@ Purge
120120
~~~~~
121121

122122
To support :ref:`cache invalidation <cache invalidate>`, register the
123-
``PurgeSubscriber``. If the default settings are right for you, you don't
123+
``PurgeListener``. If the default settings are right for you, you don't
124124
need to do anything more.
125125

126126
Purging is only allowed from the same machine by default. To purge data from
@@ -146,14 +146,14 @@ Refresh
146146
~~~~~~~
147147

148148
To support :ref:`cache refresh <cache refresh>`, register the
149-
``RefreshSubscriber``. You can pass the constructor an option to specify
149+
``RefreshListener``. You can pass the constructor an option to specify
150150
what clients are allowed to refresh cache entries. Refreshing is only allowed
151151
from the same machine by default. To refresh from other hosts, provide the
152152
IPs of the machines allowed to refresh, or provide a RequestMatcher that
153153
checks for an Authorization header or similar. *Only set one of
154154
``client_ips`` or ``client_matcher``*.
155155

156-
The refresh subscriber needs to access the ``HttpCache::fetch`` method which
156+
The refresh listener needs to access the ``HttpCache::fetch`` method which
157157
is protected on the base HttpCache class. The ``EventDispatchingHttpCache``
158158
exposes the method as public, but if you implement your own kernel, you need
159159
to overwrite the method to make it public.
@@ -174,7 +174,7 @@ User Context
174174
~~~~~~~~~~~~
175175

176176
To support :doc:`user context hashing <user-context>` you need to register the
177-
``UserContextSubscriber``. The user context is then automatically recognized
177+
``UserContextListener``. The user context is then automatically recognized
178178
based on session cookies or authorization headers. If the default settings are
179179
right for you, you don't need to do anything more. You can customize a number of
180180
options through the constructor:
@@ -230,9 +230,9 @@ options through the constructor:
230230
Cleaning the Cookie Header
231231
^^^^^^^^^^^^^^^^^^^^^^^^^^
232232

233-
By default, the UserContextSubscriber only sets the session cookie (according to
233+
By default, the UserContextListener only sets the session cookie (according to
234234
the ``session_name_prefix`` option) in the requests to the backend. If you need
235-
a different behavior, overwrite ``UserContextSubscriber::cleanupHashLookupRequest``
235+
a different behavior, overwrite ``UserContextListener::cleanupHashLookupRequest``
236236
with your own logic.
237237

238238
.. _symfonycache_customttl:
@@ -242,11 +242,11 @@ Custom TTL
242242

243243
.. include:: includes/custom-ttl.rst
244244

245-
The ``CustomTtlSubscriber`` looks at a specific header to determine the TTL,
245+
The ``CustomTtlListener`` looks at a specific header to determine the TTL,
246246
preferring that over ``s-maxage``. The default header is ``X-Reverse-Proxy-TTL``
247-
but you can customize that in the subscriber constructor::
247+
but you can customize that in the listener constructor::
248248

249-
new CustomTtlSubscriber('My-TTL-Header');
249+
new CustomTtlListener('My-TTL-Header');
250250

251251
The custom header is removed before sending the response to the client.
252252

doc/varnish-configuration.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ which IPs are allowed to issue invalidation requests. To use the provided
1616
configuration fragments, this ACL has to be named ``invalidators``. The most
1717
simple ACL, valid for all Varnish versions from 3 onwards, looks as follows:
1818

19-
.. code-block:: varnish4
19+
.. code-block:: varnish
2020
2121
# /etc/varnish/your_varnish.vcl
2222
@@ -59,7 +59,7 @@ To enable support add the following to ``your_varnish.vcl``:
5959

6060
.. configuration-block::
6161

62-
.. code-block:: varnish4
62+
.. code-block:: varnish
6363
6464
include "path-to-config/varnish/fos_purge.vcl";
6565
@@ -100,7 +100,7 @@ To enable support, add the following to ``your_varnish.vcl``:
100100

101101
.. configuration-block::
102102

103-
.. code-block:: varnish4
103+
.. code-block:: varnish
104104
105105
include "path-to-config/varnish/fos_refresh.vcl";
106106
@@ -129,7 +129,7 @@ To enable support add the following to ``your_varnish.vcl``:
129129

130130
.. configuration-block::
131131

132-
.. code-block:: varnish4
132+
.. code-block:: varnish
133133
134134
include "path-to-config/varnish/fos_ban.vcl";
135135
@@ -186,7 +186,7 @@ VCL will look like this:
186186
.. configuration-block::
187187

188188
.. literalinclude:: ../resources/config/varnish/fos_ban.vcl
189-
:language: varnish4
189+
:language: varnish
190190
:emphasize-lines: 17-22,49-50
191191
:linenos:
192192

@@ -210,7 +210,7 @@ To enable support add the following to ``your_varnish.vcl``:
210210

211211
.. configuration-block::
212212

213-
.. code-block:: varnish4
213+
.. code-block:: varnish
214214
215215
include "path-to-config/varnish/fos_user_context.vcl";
216216
include "path-to-config/varnish/fos_user_context_url.vcl";
@@ -294,7 +294,7 @@ To make the hash request cacheable, you must extract a stable user session id
294294
*before* calling ``fos_user_context_recv``. You can do this as
295295
`explained in the Varnish documentation`_:
296296

297-
.. code-block:: varnish4
297+
.. code-block:: varnish
298298
:linenos:
299299
300300
sub vcl_recv {
@@ -329,7 +329,7 @@ inline C enabled: ``-p vcc_allow_inline_c=on``. Then add the following to
329329

330330
.. configuration-block::
331331

332-
.. code-block:: varnish4
332+
.. code-block:: varnish
333333
334334
include "path-to-config/varnish/fos_custom_ttl.vcl";
335335
@@ -362,7 +362,7 @@ To enable support add the following to ``your_varnish.vcl``:
362362

363363
.. configuration-block::
364364

365-
.. code-block:: varnish4
365+
.. code-block:: varnish
366366
367367
include "path-to-config/varnish/fos_debug.vcl";
368368

src/EventListener/LogSubscriber.php renamed to src/EventListener/LogListener.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
use Psr\Log\LogLevel;
1818
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1919

20-
class LogSubscriber implements EventSubscriberInterface
20+
/**
21+
* Log when the caching proxy client can't send requests to the caching server.
22+
*/
23+
class LogListener implements EventSubscriberInterface
2124
{
2225
/**
2326
* @var LoggerInterface

src/ProxyClient/Symfony.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use FOS\HttpCache\ProxyClient\Invalidation\PurgeInterface;
1515
use FOS\HttpCache\ProxyClient\Invalidation\RefreshInterface;
16-
use FOS\HttpCache\SymfonyCache\PurgeSubscriber;
16+
use FOS\HttpCache\SymfonyCache\PurgeListener;
1717

1818
/**
1919
* Symfony HttpCache invalidator.
@@ -53,7 +53,7 @@ protected function configureOptions()
5353
{
5454
$resolver = parent::configureOptions();
5555
$resolver->setDefaults([
56-
'purge_method' => PurgeSubscriber::DEFAULT_PURGE_METHOD,
56+
'purge_method' => PurgeListener::DEFAULT_PURGE_METHOD,
5757
]);
5858

5959
return $resolver;

src/SymfonyCache/AccessControlledSubscriber.php renamed to src/SymfonyCache/AccessControlledListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
*
2626
* {@inheritdoc}
2727
*/
28-
abstract class AccessControlledSubscriber implements EventSubscriberInterface
28+
abstract class AccessControlledListener implements EventSubscriberInterface
2929
{
3030
/**
3131
* @var RequestMatcher
3232
*/
3333
private $clientMatcher;
3434

3535
/**
36-
* When creating this subscriber, you can configure a number of options.
36+
* When creating this event listener, you can configure a number of options.
3737
*
3838
* - client_matcher: RequestMatcherInterface to identify clients that are allowed to send request.
3939
* - client_ips: IP or array of IPs of clients that are allowed to send requests.

src/SymfonyCache/CacheInvalidationInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ interface CacheInvalidationInterface extends HttpKernelInterface
2626
*
2727
* This methods is triggered when the cache missed or a reload is required.
2828
*
29-
* This method is present on HttpCache but must be public to allow event subscribers to do
29+
* This method is present on HttpCache but must be public to allow event listeners to do
3030
* refresh operations.
3131
*
3232
* @param Request $request A Request instance

src/SymfonyCache/EventDispatchingHttpCache.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* public does not satisfy the interface for whatever reason. See also
2727
* http://stackoverflow.com/questions/31877844/php-trait-exposing-a-method-and-interfaces )
2828
*
29-
* CacheInvalidator kernels support event subscribers that can act on the
29+
* CacheInvalidator kernels support event listeners that can act on the
3030
* events defined in FOS\HttpCache\SymfonyCache\Events and may alter the
3131
* request flow.
3232
*
@@ -62,7 +62,7 @@ public function getEventDispatcher()
6262
}
6363

6464
/**
65-
* Add subscriber.
65+
* Add an event subscriber.
6666
*
6767
* @param EventSubscriberInterface $subscriber
6868
*/

0 commit comments

Comments
 (0)