Skip to content

Commit 2ac2b93

Browse files
authored
Merge pull request #577 from FriendsOfSymfony/drop-sf-3
drop symfony 3 and 4.3 support
2 parents f45d130 + 1322533 commit 2ac2b93

File tree

23 files changed

+89
-508
lines changed

23 files changed

+89
-508
lines changed

.github/workflows/php.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,48 +20,54 @@ jobs:
2020
- php-version: '7.3'
2121
- php-version: '7.4'
2222
- php-version: '8.0'
23-
# Test Symfony LTS versions. Read more at https://github.com/symfony/lts
24-
- php-version: '7.4'
25-
dependencies: 'symfony/lts:^3'
2623
- php-version: '8.0'
2724
symfony-version: '^4'
2825
- php-version: '8.0'
2926
symfony-version: '^5'
3027
# Minimum supported dependencies with the oldest PHP version
3128
- php-version: '7.3'
3229
composer-flag: '--prefer-stable --prefer-lowest'
30+
symfony-version: '4.4'
3331
# Test latest unreleased versions
3432
- php-version: '8.0'
3533
symfony-version: '^5'
3634
stability: 'dev'
3735
name: PHP ${{ matrix.php-version }} Test on Symfony ${{ matrix.symfony-version }} ${{ matrix.dependencies}} ${{ matrix.stability }} ${{ matrix.composer-flag }}
3836
steps:
37+
3938
- name: Pull the code
4039
uses: actions/checkout@v2
40+
4141
- name: Install PHP and Composer
4242
uses: shivammathur/setup-php@v2
4343
with:
4444
php-version: ${{ matrix.php-version }}
45-
tools: composer:v2
46-
- name: Check PHP Version
47-
run: php -v
45+
tools: composer:v2, flex
46+
coverage: none
47+
4848
- name: Stability
4949
run: composer config minimum-stability ${{ matrix.stability }}
5050
if: ${{ matrix.stability }}
51+
5152
- name: Additional require
5253
run: composer require --no-update ${{ matrix.dependencies }}
5354
if: ${{ matrix.dependencies }}
54-
- name: Symfony version
55-
run: composer require --no-update symfony/flex && composer config extra.symfony.require ${{ matrix.symfony-version}}
56-
if: ${{ matrix.symfony-version }}
55+
5756
- name: Composer update
58-
run: composer update ${{ matrix.composer-flag }} --prefer-dist --no-interaction
57+
env:
58+
SYMFONY_REQUIRE: ${{ matrix.symfony-version }}
59+
run: |
60+
composer update ${{ matrix.composer-flag }} --prefer-dist --no-interaction --no-progress
61+
vendor/bin/simple-phpunit install
62+
5963
- name: Composer validate
6064
run: composer validate --strict --no-check-lock
6165
if: ${{ matrix.stability != 'dev' }}
66+
6267
- name: Run tests
6368
run: php vendor/bin/simple-phpunit -v
6469
if: ${{ matrix.stability != 'dev' }}
70+
6571
- name: Run tests allow to fail
6672
run: php vendor/bin/simple-phpunit -v || true
6773
continue-on-error: true

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Changelog
22
=========
33

4+
unreleased
5+
----------
6+
7+
* Drop support for Symfony 3 and 4.3 (keep using 2.11.* for legacy projects).
8+
49
2.11.2
510
------
611

composer.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
"require": {
2424
"php": "^7.3 || ^8.0",
2525
"friendsofsymfony/http-cache": "^2.6",
26-
"symfony/framework-bundle": "^3.4.26 || ^4.2.7 || ^5.0",
27-
"symfony/http-foundation": "^3.4.26 || ^4.2.7 || ^5.0",
28-
"symfony/http-kernel": "^3.4.26 || ^4.2.7 || ^5.0"
26+
"symfony/framework-bundle": "^4.4.0 || ^5.0",
27+
"symfony/http-foundation": "^4.4.0 || ^5.0",
28+
"symfony/http-kernel": "^4.4.0 || ^5.0"
2929
},
3030
"require-dev": {
3131
"php-http/guzzle7-adapter": "^0.1.1",
@@ -35,20 +35,20 @@
3535
"guzzlehttp/guzzle": "^7.2",
3636
"mockery/mockery": "^1.3.2",
3737
"monolog/monolog": "*",
38-
"sensio/framework-extra-bundle": "^3.0 || ^4.0 || ^5.5.1",
38+
"sensio/framework-extra-bundle": "^4.0 || ^5.5.1",
3939
"doctrine/annotations": "^1.11",
40-
"symfony/browser-kit": "^3.4.4 || ^4.2.7 || ^5.0",
41-
"symfony/console": "^3.4.26 || ^4.2.7 || ^5.0",
42-
"symfony/finder": "^3.4.26 || ^4.2.7 || ^5.0",
40+
"symfony/browser-kit": "^4.4 || ^5.0",
41+
"symfony/console": "^4.4 || ^5.0",
42+
"symfony/finder": "^4.4 || ^5.0",
4343
"symfony/phpunit-bridge": "v5.3.7",
44-
"symfony/security-bundle": "^3.4.26 || ^4.2.7 || ^5.0",
45-
"symfony/twig-bundle": "^3.4.26 || ^4.2.7 || ^5.0",
44+
"symfony/security-bundle": "^4.4 || ^5.0",
45+
"symfony/twig-bundle": "^4.4 || ^5.0",
4646
"twig/twig": "^2.13",
47-
"symfony/yaml": "^3.4.26 || ^4.2.7 || ^5.0",
48-
"symfony/css-selector": "^3.4.26 || ^4.2.7 || ^5.0",
49-
"symfony/expression-language": "^3.4.26 || ^4.2.7 || ^5.0",
50-
"symfony/monolog-bundle": "^3.0 || ^4.2.7 || ^5.0",
51-
"symfony/routing": "^3.4.26 || ^4.2.7 || ^5.0",
47+
"symfony/yaml": "^4.4 || ^5.0",
48+
"symfony/css-selector": "^4.4 || ^5.0",
49+
"symfony/expression-language": "^4.4 || ^5.0",
50+
"symfony/monolog-bundle": "^3.0",
51+
"symfony/routing": "^4.4 || ^5.0",
5252
"matthiasnoback/symfony-dependency-injection-test": "^4.0",
5353
"sebastian/exporter": "^2.0"
5454
},

src/DependencyInjection/Compiler/SessionListenerPass.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,10 @@
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
1616

1717
/**
18-
* Undo our workarounds for the Symfony session listener when the session
19-
* system of Symfony has not been activated.
20-
*
21-
* - Set the hasSessionListener option of the UserContextListener to false to
22-
* avoid the AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER being
23-
* leaked to clients.
24-
* - Remove the session listener decorator we configured.
18+
* If no session_listener is configured, change the hasSessionListener flag of
19+
* the UserContextListener to false to avoid the header
20+
* AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER from being leaked to
21+
* the client.
2522
*/
2623
class SessionListenerPass implements CompilerPassInterface
2724
{
@@ -38,6 +35,5 @@ public function process(ContainerBuilder $container)
3835
$contextListener = $container->getDefinition('fos_http_cache.event_listener.user_context');
3936
$contextListener->setArgument(5, false);
4037
}
41-
$container->removeDefinition('fos_http_cache.user_context.session_listener');
4238
}
4339
}

src/DependencyInjection/FOSHttpCacheExtension.php

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@
2323
use Symfony\Component\DependencyInjection\ChildDefinition;
2424
use Symfony\Component\DependencyInjection\ContainerBuilder;
2525
use Symfony\Component\DependencyInjection\Definition;
26-
use Symfony\Component\DependencyInjection\DefinitionDecorator;
2726
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
2827
use Symfony\Component\DependencyInjection\Reference;
2928
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
30-
use Symfony\Component\HttpKernel\Kernel;
3129
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
3230

3331
/**
@@ -202,7 +200,7 @@ private function parseRuleMatcher(ContainerBuilder $container, array $match)
202200
}
203201

204202
$container
205-
->setDefinition($id, $this->createChildDefinition('fos_http_cache.rule_matcher'))
203+
->setDefinition($id, new ChildDefinition('fos_http_cache.rule_matcher'))
206204
->replaceArgument(0, $requestMatcher)
207205
->replaceArgument(1, $responseMatcher)
208206
;
@@ -231,7 +229,7 @@ private function parseRequestMatcher(ContainerBuilder $container, array $match)
231229

232230
if (!$container->hasDefinition($id)) {
233231
$container
234-
->setDefinition($id, $this->createChildDefinition('fos_http_cache.request_matcher'))
232+
->setDefinition($id, new ChildDefinition('fos_http_cache.request_matcher'))
235233
->setArguments($arguments)
236234
;
237235

@@ -254,15 +252,15 @@ private function parseResponseMatcher(ContainerBuilder $container, array $config
254252
$id = 'fos_http_cache.cache_control.expression.'.md5(serialize($config['additional_response_status']));
255253
if (!$container->hasDefinition($id)) {
256254
$container
257-
->setDefinition($id, $this->createChildDefinition('fos_http_cache.response_matcher.cache_control.cacheable_response'))
255+
->setDefinition($id, new ChildDefinition('fos_http_cache.response_matcher.cache_control.cacheable_response'))
258256
->setArguments([$config['additional_response_status']])
259257
;
260258
}
261259
} elseif (!empty($config['match_response'])) {
262260
$id = 'fos_http_cache.cache_control.match_response.'.md5($config['match_response']);
263261
if (!$container->hasDefinition($id)) {
264262
$container
265-
->setDefinition($id, $this->createChildDefinition('fos_http_cache.response_matcher.cache_control.expression'))
263+
->setDefinition($id, new ChildDefinition('fos_http_cache.response_matcher.cache_control.expression'))
266264
->replaceArgument(0, $config['match_response'])
267265
;
268266
}
@@ -318,19 +316,6 @@ private function loadUserContext(ContainerBuilder $container, XmlFileLoader $loa
318316
->addTag(HashGeneratorPass::TAG_NAME)
319317
->setAbstract(false);
320318
}
321-
322-
// Only decorate default SessionListener for Symfony 3.4 - 4.0
323-
// For Symfony 4.1+, the UserContextListener sets the header that tells
324-
// the SessionListener to leave the cache-control header unchanged.
325-
if (version_compare(Kernel::VERSION, '3.4', '>=')
326-
&& version_compare(Kernel::VERSION, '4.1', '<')
327-
) {
328-
$container->getDefinition('fos_http_cache.user_context.session_listener')
329-
->setArgument(1, strtolower($config['user_hash_header']))
330-
->setArgument(2, $completeUserIdentifierHeaders);
331-
} else {
332-
$container->removeDefinition('fos_http_cache.user_context.session_listener');
333-
}
334319
}
335320

336321
private function loadProxyClient(ContainerBuilder $container, XmlFileLoader $loader, array $config)
@@ -622,20 +607,4 @@ private function getDefaultProxyClient(array $config)
622607

623608
throw new InvalidConfigurationException('No proxy client configured');
624609
}
625-
626-
/**
627-
* Build the child definition with fallback for Symfony versions < 3.3.
628-
*
629-
* @param string $id Id of the service to extend
630-
*
631-
* @return ChildDefinition|DefinitionDecorator
632-
*/
633-
private function createChildDefinition($id)
634-
{
635-
if (class_exists(ChildDefinition::class)) {
636-
return new ChildDefinition($id);
637-
}
638-
639-
return new DefinitionDecorator($id);
640-
}
641610
}

src/EventListener/SessionListener.php

Lines changed: 0 additions & 105 deletions
This file was deleted.

src/EventListener/UserContextListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function onKernelRequest(UserContextRequestEvent $event)
164164
$response->setClientTtl($this->options['ttl']);
165165
$response->setVary($this->options['user_identifier_headers']);
166166
$response->setPublic();
167-
if ($this->hasSessionListener && version_compare('4.1', Kernel::VERSION, '<=')) {
167+
if ($this->hasSessionListener) {
168168
// header to avoid Symfony SessionListener overwriting the response to private
169169
$response->headers->set(AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER, 1);
170170
}
@@ -230,8 +230,8 @@ public function onKernelResponse(UserContextResponseEvent $event)
230230
$vary[] = $this->options['user_hash_header'];
231231
}
232232

233-
// For Symfony 4.1+ if user hash header was in vary or just added here by "add_vary_on_hash"
234-
if ($this->hasSessionListener && \version_compare('4.1', Kernel::VERSION, '<=') && in_array($this->options['user_hash_header'], $vary)) {
233+
// user hash header was in vary or just added here by "add_vary_on_hash"
234+
if ($this->hasSessionListener && in_array($this->options['user_hash_header'], $vary)) {
235235
// header to avoid Symfony SessionListener overwriting the response to private
236236
$response->headers->set(AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER, 1);
237237
}

src/FOSHttpCacheBundle.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use FOS\HttpCacheBundle\DependencyInjection\Compiler\TagListenerPass;
1919
use Symfony\Component\DependencyInjection\ContainerBuilder;
2020
use Symfony\Component\HttpKernel\Bundle\Bundle;
21-
use Symfony\Component\HttpKernel\Kernel;
2221

2322
class FOSHttpCacheBundle extends Bundle
2423
{
@@ -30,17 +29,10 @@ public function build(ContainerBuilder $container)
3029
$container->addCompilerPass(new LoggerPass());
3130
$container->addCompilerPass(new TagListenerPass());
3231
$container->addCompilerPass(new HashGeneratorPass());
33-
if (version_compare(Kernel::VERSION, '3.4', '>=')
34-
&& version_compare(Kernel::VERSION, '4.1', '<')
35-
) {
36-
$container->addCompilerPass(new SessionListenerPass());
37-
}
32+
$container->addCompilerPass(new SessionListenerPass());
3833

39-
// Symfony 3.3 and higher
40-
if (method_exists($container, 'registerForAutoconfiguration')) {
41-
$container
42-
->registerForAutoconfiguration(ContextProvider::class)
43-
->addTag('fos_http_cache.user_context_provider');
44-
}
34+
$container
35+
->registerForAutoconfiguration(ContextProvider::class)
36+
->addTag('fos_http_cache.user_context_provider');
4537
}
4638
}

0 commit comments

Comments
 (0)