8000 Merge branch '3.4' · symfony/symfony@0ab92ec · GitHub
[go: up one dir, main page]

Skip to content

Commit 0ab92ec

Browse files
committed
Merge branch '3.4'
* 3.4: (26 commits) bumped Symfony version to 3.3.11 updated VERSION for 3.3.10 updated CHANGELOG for 3.3.10 bumped Symfony version to 2.8.29 updated VERSION for 2.8.28 updated CHANGELOG for 2.8.28 bumped Symfony version to 2.7.36 updated VERSION for 2.7.35 update CONTRIBUTORS for 2.7.35 updated CHANGELOG for 2.7.35 Added deprecation to cwd not existing Fixes #18249 [Session] fix MongoDb session handler to gc all expired sessions 10000 Add changelog for deprecated DbalSessionHandler [Security] Look at headers for switch user username parameter Updated Test name and exception name to be more accurate newline at end of file changed exception message Ahh, I see. It actually wants a newline! Removed newline Created new Exception to throw and modified tests. ...
2 parents fe0b162 + a165f1b commit 0ab92ec

File tree

15 files changed

+157
-11
lines changed

15 files changed

+157
-11
lines changed

CHANGELOG-3.3.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,44 @@ in 3.3 minor versions.
77
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
88
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v3.3.0...v3.3.1
99

10+
* 3.3.10 (2017-10-05)
11+
12+
* bug #23906 Added support for guards when advancing workflow from a command (GDIBass)
13+
* bug #24448 [Session] fix MongoDb session handler to gc all expired sessions (Tobion)
14+
* bug #24431 [FrameworkBundle] Fix bad interface hint in AbstractController (nicolas-grekas)
15+
* bug #24419 [Cache] Fix race condition in TagAwareAdapter (nicolas-grekas)
16+
* bug #24417 [Yaml] parse references on merge keys (xabbuh)
17+
* bug #24416 [Yaml] treat trailing backslashes in multi-line strings (xabbuh)
18+
* bug #24421 [Config] Fix dumped files invalidation by OPCache (nicolas-grekas)
19+
* bug #24418 [DI] Allow setting any public non-initialized services (nicolas-grekas)
20+
* bug #23980 Tests and fix for issue in array model data in EntityType field with multiple=true (stoccc)
21+
* bug #22586 [Form] Fixed PercentToLocalizedStringTransformer to accept both comma and dot as decimal separator, if possible (aaa2000)
22+
* bug #24157 [Intl] Fixed support of Locale::getFallback (lyrixx)
23+
* bug #24198 [HttpFoundation] Fix file upload multiple with no files (enumag)
24+
* bug #24379 [PHPUnitBridge] don't remove when set to empty string (Simperfit)
25+
* bug #24036 [Form] Fix precision of MoneyToLocalizedStringTransformer's divisions and multiplications (Rubinum)
26+
* bug #24191 [DependencyInjection] include file and line number i 1E0A n deprecation (xabbuh)
27+
* bug #24367 PdoSessionHandler: fix advisory lock for pgsql (Tobion)
28+
* bug #24189 [Yaml] parse merge keys with PARSE_OBJECT_FOR_MAP flag (xabbuh)
29+
* bug #24243 HttpCache does not consider ESI resources in HEAD requests (mpdude)
30+
* bug #24237 [WebProfilerBundle] Added missing link to profile token (vtsykun)
31+
* bug #24244 TwigBundle exception/deprecation tweaks (ro0NL)
32+
* bug #24281 [TwigBundle] Remove profiler related scripting (ro0NL, javiereguiluz)
33+
* bug #24251 [PropertyAccess] Set a NullLogger in ApcuAdapter when Apcu is disabled in CLI (iamluc)
34+
* bug #24304 [FrameworkBundle] Fix Routing\DelegatingLoader (nicolas-grekas)
35+
* bug #24305 [HttpKernel] Make array vs "::" controller definitions consistent (nicolas-grekas)
36+
* bug #24255 [TwigBundle] Break long lines in exceptions (kevin-verschaeve)
37+
* bug #24219 [Console] Preserving line breaks between sentences according to the exception message (yceruto)
38+
* bug #24192 [PhpUnitBridge] do not require an error context (xabbuh)
39+
* bug #23722 [Form] Fixed GroupSequence with "constraints" option (HeahDude)
40+
* bug #22321 [Filesystem] Fixed makePathRelative (ausi)
41+
* bug #24234 [DI] Fix decorated service merge in ResolveInstanceofConditionalsPass (dunglas)
42+
* bug #24203 [Security] Preserve URI fragment in HttpUtils::generateUri() (chalasr)
43+
* bug #24199 [DI] Fix non-instantiables auto-discovery (nicolas-grekas)
44+
* bug #23473 [Filesystem] mirror - fix copying content with same name as source/target. (gitlost)
45+
* bug #24177 [FrameworkBundle] Add support to environment variables APP_ENV/DEBUG in KernelTestCase (yceruto)
46+
* bug #24162 [WebProfilerBundle] fixed TemplateManager when using Twig 2 without compat interfaces (fabpot)
47+
1048
* 3.3.9 (2017-09-11)
1149

1250
* bug #24141 [DomCrawler] Fix conversion to int on GetPhpFiles (MaraBlaga)

UPGRADE-3.4.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ Debug
6363

6464
* Support for stacked errors in the `ErrorHandler` is deprecated and will be removed in Symfony 4.0.
6565

66+
DoctrineBridge
67+
--------------
68+
69+
* Deprecated `Symfony\Bridge\Doctrine\HttpFoundation\DbalSessionHandler` and
70+
`Symfony\Bridge\Doctrine\HttpFoundation\DbalSessionHandlerSchema`. Use
71+
`Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler` instead.
72+
6673
EventDispatcher
6774
---------------
6875

@@ -300,6 +307,8 @@ Process
300307
* The `Symfony\Component\Process\ProcessBuilder` class has been deprecated,
301308
use the `Symfony\Component\Process\Process` class directly instead.
302309

310+
* Calling `Process::start()` without setting a valid working directory (via `setWorkingDirectory()` or constructor) beforehand is deprecated and will throw an exception in 4.0.
311+
303312
Profiler
304313
--------
305314

UPGRADE-4.0.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,13 @@ DependencyInjection
186186

187187
* The `ExtensionCompilerPass` has been moved to before-optimization passes with priority -1000.
188188

189+
DoctrineBridge
190+
--------------
191+
192+
* The `Symfony\Bridge\Doctrine\HttpFoundation\DbalSessionHandler` and
193+
`Symfony\Bridge\Doctrine\HttpFoundation\DbalSessionHandlerSchema` have been removed. Use
194+
`Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler` instead.
195+
189196
EventDispatcher
190197
---------------
191198

@@ -639,6 +646,8 @@ Ldap
639646
Process
640647
-------
641648

649+
* Passing a not existing working directory to the constructor of the `Symfony\Component\Process\Process` class is not supported anymore.
650+
642651
* The `Symfony\Component\Process\ProcessBuilder` class has been removed,
643652
use the `Symfony\Component\Process\Process` class directly instead.
644653

src/Symfony/Bridge/Doctrine/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ CHANGELOG
1616

1717
* added support for doctrine/dbal v2.6 types
1818
* added cause of UniqueEntity constraint violation
19+
* deprecated `DbalSessionHandler` and `DbalSessionHandlerSchema` in favor of
20+
`Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler`
1921

2022
3.1.0
2123
-----

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function testSwitchedUserExit()
5454
public function testSwitchUserStateless()
5555
{
5656
$client = $this->createClient(array('test_case' => 'JsonLogin', 'root_config' => 'switchuser_stateless.yml'));
57-
$client->request('POST', '/chk', array('_switch_user' => 'dunglas'), array(), array('CONTENT_TYPE' => 'application/json'), '{"user": {"login": "user_can_switch", "password": "test"}}');
57+
$client->request('POST', '/chk', array(), array(), array('HTTP_X_SWITCH_USER' => 'dunglas', 'CONTENT_TYPE' => 'application/json'), '{"user": {"login": "user_can_switch", "password": "test"}}');
5858
$response = $client->getResponse();
5959

6060
$this->assertInstanceOf(JsonResponse::class, $response);

src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/JsonLogin/switchuser_stateless.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ security:
1010
firewalls:
1111
main:
1212
switch_user:
13+
parameter: X-Switch-User
1314
stateless: true

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function destroy($sessionId)
116116
*/
117117
public function gc($maxlifetime)
118118
{
119-
$this->getCollection()->deleteOne(array(
119+
$this->getCollection()->deleteMany(array(
120120
$this->options['expiry_field'] => array('$lt' => new \MongoDB\BSON\UTCDateTime()),
121121
));
122122

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public function testGc()
181181
->will($this->returnValue($collection));
182182

183183
$collection->expects($this->once())
184-
->method('deleteOne')
184+
->method('deleteMany')
185185
->will($this->returnCallback(function ($criteria) {
186186
$this->assertInstanceOf(\MongoDB\BSON\UTCDateTime::class, $criteria[$this->options['expiry_field']]['$lt']);
187187
$this->assertGreaterThanOrEqual(time() - 1, round((string) $criteria[$this->options['expiry_field']]['$lt'] / 1000));

src/Symfony/Component/Process/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ CHANGELOG
2020
-----
2121

2222
* deprecated the ProcessBuilder class
23+
* deprecated calling `Process::start()` without setting a valid working directory beforehand (via `setWorkingDirectory()` or constructor)
2324

2425
3.3.0
2526
-----

src/Symfony/Component/Process/Process.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,14 @@ public function start(callable $callback = null, array $env = array())
296296
$ptsWorkaround = fopen(__FILE__, 'r');
297297
}
298298

299+
if (!is_dir($this->cwd)) {
300+
if ('\\' === DIRECTORY_SEPARATOR) {
301+
throw new RuntimeException('The provided cwd does not exist.');
302+
}
303+
304+
@trigger_error('The provided cwd does not exist. Command is currently ran against getcwd(). This behavior is deprecated since version 3.4 and will be removed in 4.0.', E_USER_DEPRECATED);
305+
}
306+
299307
$this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, null, $options);
300308

301309
foreach ($envBackup as $k => $v) {

src/Symfony/Component/Process/Tests/ProcessTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,46 @@ protected function tearDown()
4747
}
4848
}
4949

50+
/**
51+
* @group legacy
52+
* @expectedDeprecation The provided cwd does not exist. Command is currently ran against getcwd(). This behavior is deprecated since version 3.4 and will be removed in 4.0.
53+
*/
54+
public function testInvalidCwd()
55+
{
56+
if ('\\' === DIRECTORY_SEPARATOR) {
57+
$this->markTestSkipped('Windows handles this automatically.');
58+
}
59+
60+
// Check that it works fine if the CWD exists
61+
$cmd = new Process('echo test', __DIR__);
62+
$cmd->run();
63+
64+
$cmd = new Process('echo test', __DIR__.'/notfound/');
65+
$cmd->run();
66+
}
67+
68+
/**
69+
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
70+
* @expectedExceptionMessage The provided cwd does not exist.
71+
*/
72+
public function testInvalidCwdOnWindows()
73+
{
74+
if ('\\' !== DIRECTORY_SEPARATOR) {
75+
$this->markTestSkipped('Unix handles this automatically.');
76+
}
77+
78+
try {
79+
// Check that it works fine if the CWD exists
80+
$cmd = new Process('echo test', __DIR__);
81+
$cmd->run();
82+
} catch (\Exception $e) {
83+
$this->fail($e);
84+
}
85+
86+
$cmd = new Process('echo test', __DIR__.'/notfound/');
87+
$cmd->run();
88+
}
89+
5090
public function testThatProcessDoesNotThrowWarningDuringRun()
5191
{
5292
if ('\\' === DIRECTORY_SEPARATOR) {

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,17 @@ public function __construct(TokenStorageInterface $tokenStorage, UserProviderInt
7979
public function handle(GetResponseEvent $event)
8080
{
8181
$request = $event->getRequest();
82+
$username = $request->get($this->usernameParameter) ?: $request->headers->get($this->usernameParameter);
8283

83-
if (!$request->get($this->usernameParameter)) {
84+
if (!$username) {
8485
return;
8586
}
8687

87-
if (self::EXIT_VALUE === $request->get($this->usernameParameter)) {
88+
if (self::EXIT_VALUE === $username) {
8889
$this->tokenStorage->setToken($this->attemptExitUser($request));
8990
} else {
9091
try {
91-
$this->tokenStorage->setToken($this->attemptSwitchUser($request));
92+
$this->tokenStorage->setToken($this->attemptSwitchUser($request, $username));
9293
} catch (AuthenticationException $e) {
9394
throw new \LogicException(sprintf('Switch User failed: "%s"', $e->getMessage()));
9495
}
@@ -106,20 +107,21 @@ public function handle(GetResponseEvent $event)
106107
/**
107108
* Attempts to switch to another user.
108109
*
109-
* @param Request $request A Request instance
110+
* @param Request $request A Request instance
111+
* @param string $username
110112
*
111113
* @return TokenInterface|null The new TokenInterface if successfully switched, null otherwise
112114
*
113115
* @throws \LogicException
114116
* @throws AccessDeniedException
115117
*/
116-
private function attemptSwitchUser(Request $request)
118+
private function attemptSwitchUser(Request $request, $username)
117119
{
118120
$token = $this->tokenStorage->getToken();
119121
$originalToken = $this->getOriginalToken($token);
120122

121123
if (false !== $originalToken) {
122-
if ($token->getUsername() === $request->get($this->usernameParameter)) {
124+
if ($token->getUsername() === $username) {
123125
return $token;
124126
}
125127

@@ -133,8 +135,6 @@ private function attemptSwitchUser(Request $request)
133135
throw $exception;
134136
}
135137

136-
$username = $request->get($this->usernameParameter);
137-
138138
if (null !== $this->logger) {
139139
$this->logger->info('Attempting to switch to user.', array('username' => $username));
140140
}

src/Symfony/Component/Workflow/EventListener/GuardListener.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
1717
use Symfony\Component\Security\Core\Role\RoleHierarchyInterface;
1818
use Symfony\Component\Workflow\Event\GuardEvent;
19+
use Symfony\Component\Workflow\Exception\InvalidTokenConfigurationException;
1920

2021
/**
2122
* @author Grégoire Pineau <lyrixx@lyrixx.info>
@@ -55,6 +56,10 @@ private function getVariables(GuardEvent $event): array
5556
{
5657
$token = $this->tokenStorage->getToken();
5758

59+
if (null === $token) {
60+
throw new InvalidTokenConfigurationException(sprintf('There are no tokens available for workflow %s.', $event->getWorkflowName()));
61+
}
62+
5863
if (null !== $this->roleHierarchy) {
5964
$roles = $this->roleHierarchy->getReachableRoles($token->getRoles());
6065
} else {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
namespace Symfony\Component\Workflow\Exception;
13+
14+
/**
15+
* Thrown by GuardListener when there is no token set, but guards are placed on a transition.
16+
*
17+
* @author Matt Johnson <matj1985@gmail.com>
18+
*/
19+
class InvalidTokenConfigurationException extends LogicException implements ExceptionInterface
20+
{
21+
}

src/Symfony/Component/Workflow/Tests/EventListener/GuardListenerTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ public function testWithSupportedEventAndAccept()
6969
$this->assertTrue($event->isBlocked());
7070
}
7171

72+
/**
73+
* @expectedException \Symfony\Component\Workflow\Exception\InvalidTokenConfigurationException
74+
* @expectedExceptionMessage There are no tokens available for workflow unnamed.
75+
*/
76+
public function testWithNoTokensInTokenStorage()
77+
{
78+
$event = $this->createEvent();
79+
$this->tokenStorage->setToken(null);
80+
81+
$this->listener->onTransition($event, 'event_name_a');
82+
}
83+
7284
private function createEvent()
7385
{
7486
$subject = new \stdClass();

0 commit comments

Comments
 (0)
0