Skip to content

Commit 2dedacb

Browse files
Merge branch '3.4' into 4.1
* 3.4: [travis][appveyor] use symfony/flex to accelerate builds Add missing stderr redirection clean up unused code [Filesystem] Add test to prevent regression when using array|resource with dumpFile [Security] Call AccessListener after LogoutListener
2 parents 68a9a07 + d351daa commit 2dedacb

File tree

12 files changed

+118
-47
lines changed

12 files changed

+118
-47
lines changed

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,15 @@ install:
187187
SYMFONY_VERSION=$(cat composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*')
188188
fi
189189
190+
- |
191+
# Install symfony/flex
192+
if [[ $deps = low ]]; then
193+
export SYMFONY_REQUIRE='>=2.3'
194+
else
195+
export SYMFONY_REQUIRE=">=$SYMFONY_VERSION"
196+
fi
197+
composer global require symfony/flex dev-master
198+
190199
- |
191200
# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number than the next one
192201
[[ $deps = high && ${SYMFONY_VERSION%.*} != $(git show $(git ls-remote --heads | grep -FA1 /$SYMFONY_VERSION | tail -n 1):composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9]*' | head -n 1) ]] && LEGACY=,legacy

appveyor.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ init:
1010
- SET PATH=c:\php;%PATH%
1111
- SET COMPOSER_NO_INTERACTION=1
1212
- SET SYMFONY_DEPRECATIONS_HELPER=strict
13+
- SET "SYMFONY_REQUIRE=>=3.4"
1314
- SET ANSICON=121x90 (121x90)
1415
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Command Processor" /v DelayedExpansion /t REG_DWORD /d 1 /f
1516

@@ -40,9 +41,10 @@ install:
4041
- echo extension=php_curl.dll >> php.ini-max
4142
- copy /Y php.ini-max php.ini
4243
- cd c:\projects\symfony
43-
- IF NOT EXIST composer.phar (appveyor DownloadFile https://getcomposer.org/download/1.3.0/composer.phar)
44+
- IF NOT EXIST composer.phar (appveyor DownloadFile https://github.com/composer/composer/releases/download/1.7.1/composer.phar)
4445
- php composer.phar self-update
4546
- copy /Y .composer\* %APPDATA%\Composer\
47+
- php composer.phar global require --no-progress symfony/flex dev-master
4648
- php .github/build-packages.php "HEAD^" src\Symfony\Bridge\PhpUnit
4749
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev)
4850
- php composer.phar update --no-progress --no-suggest --ansi

src/Symfony/Bridge/PhpUnit/Tests/CoverageListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function test()
1212
$this->markTestSkipped('This test cannot be run on Windows.');
1313
}
1414

15-
exec('type phpdbg', $output, $returnCode);
15+
exec('type phpdbg 2> /dev/null', $output, $returnCode);
1616

1717
if (\PHP_VERSION_ID >= 70000 && 0 === $returnCode) {
1818
$php = 'phpdbg -qrr';

src/Symfony/Bundle/SecurityBundle/Tests/Functional/LogoutTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,14 @@ public function testCsrfTokensAreClearedOnLogout()
4949

5050
$this->assertFalse(static::$container->get('security.csrf.token_storage')->hasToken('foo'));
5151
}
52+
53+
public function testAccessControlDoesNotApplyOnLogout()
54+
{
55+
$client = $this->createClient(array('test_case' => 'LogoutAccess', 'root_config' => 'config.yml'));
56+
57+
$client->request('POST', '/login', array('_username' => 'johannes', '_password' => 'test'));
58+
$client->request('GET', '/logout');
59+
60+
$this->assertRedirect($client->getResponse(), '/');
61+
}
5262
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
13+
use Symfony\Bundle\SecurityBundle\SecurityBundle;
14+
15+
return array(
16+
new FrameworkBundle(),
17+
new SecurityBundle(),
18+
);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
imports:
2+
- { resource: ./../config/framework.yml }
3+
4+
security:
5+
encoders:
6+
Symfony\Component\Security\Core\User\User: plaintext
7+
8+
providers:
9+
in_memory:
10+
memory:
11+
users:
12+
johannes: { password: test, roles: [ROLE_USER] }
13+
14+
firewalls:
15+
default:
16+
form_login:
17+
check_path: login
18+
remember_me: true
19+
require_previous_session: false
20+
logout: ~
21+
anonymous: ~
22+
stateless: true
23+
24+
access_control:
25+
- { path: ^/login$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
26+
- { path: .*, roles: IS_AUTHENTICATED_FULLY }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
login:
2+
path: /login
3+
4+
logout:
5+
path: /logout

src/Symfony/Bundle/SecurityBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": "^7.1.3",
2020
"ext-xml": "*",
21-
"symfony/security": "^4.1.1",
21+
"symfony/security": "^4.1.4",
2222
"symfony/dependency-injection": "^3.4.3|^4.0.3",
2323
"symfony/http-kernel": "^4.1"
2424
},

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,6 +1467,31 @@ public function testDumpFile()
14671467
}
14681468
}
14691469

1470+
public function testDumpFileWithArray()
1471+
{
1472+
$filename = $this->workspace.\DIRECTORY_SEPARATOR.'foo'.\DIRECTORY_SEPARATOR.'baz.txt';
1473+
1474+
$this->filesystem->dumpFile($filename, array('bar'));
1475+
1476+
$this->assertFileExists($filename);
1477+
$this->assertStringEqualsFile($filename, 'bar');
1478+
}
1479+
1480+
public function testDumpFileWithResource()
1481+
{
1482+
$filename = $this->workspace.\DIRECTORY_SEPARATOR.'foo'.\DIRECTORY_SEPARATOR.'baz.txt';
1483+
1484+
$resource = fopen('php://memory', 'rw');
1485+
fwrite($resource, 'bar');
1486+
fseek($resource, 0);
1487+
1488+
$this->filesystem->dumpFile($filename, $resource);
1489+
1490+
fclose($resource);
1491+
$this->assertFileExists($filename);
1492+
$this->assertStringEqualsFile($filename, 'bar');
1493+
}
1494+
14701495
public function testDumpFileOverwritesAnExistingFile()
14711496
{
14721497
$filename = $this->workspace.\DIRECTORY_SEPARATOR.'foo.txt';

src/Symfony/Component/Security/Http/Firewall.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
1717
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
1818
use Symfony\Component\HttpKernel\KernelEvents;
19+
use Symfony\Component\Security\Http\Firewall\AccessListener;
1920

2021
/**
2122
* Firewall uses a FirewallMap to register security listeners for the given
@@ -49,20 +50,31 @@ public function onKernelRequest(GetResponseEvent $event)
4950
// register listeners for this firewall
5051
$listeners = $this->map->getListeners($event->getRequest());
5152

52-
$authenticationListeners = $listeners[0];
53-
$exceptionListener = $listeners[1];
54-
$logoutListener = isset($listeners[2]) ? $listeners[2] : null;
53+
$accessListener = null;
54+
$authenticationListeners = array();
5555

56-
if (null !== $exceptionListener) {
56+
foreach ($listeners[0] as $listener) {
57+
if ($listener instanceof AccessListener) {
58+
$accessListener = $listener;
59+
} else {
60+
$authenticationListeners[] = $listener;
61+
}
62+
}
63+
64+
if (null !== $exceptionListener = $listeners[1]) {
5765
$this->exceptionListeners[$event->getRequest()] = $exceptionListener;
5866
$exceptionListener->register($this->dispatcher);
5967
}
6068

61-
$this->handleRequest($event, $authenticationListeners);
69+
if (null !== $logoutListener = isset($listeners[2]) ? $listeners[2] : null) {
70+
$authenticationListeners[] = $logoutListener;
71+
}
6272

63-
if (null !== $logoutListener) {
64-
$logoutListener->handle($event);
73+
if (null !== $accessListener) {
74+
$authenticationListeners[] = $accessListener;
6575
}
76+
77+
$this->handleRequest($event, $authenticationListeners);
6678
}
6779

6880
public function onKernelFinishRequest(FinishRequestEvent $event)

0 commit comments

Comments
 (0)