Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9a4a969

Browse filesBrowse files
committed
Merge branch '5.0'
* 5.0: Fix wrong namespaces Fix wrong namespaces Fix the reporting of deprecations in twig:lint forward multiple attributes voting flag bumped Symfony version to 5.0.8 updated VERSION for 5.0.7 updated CHANGELOG for 5.0.7 bumped Symfony version to 4.4.8 updated VERSION for 4.4.7 updated CHANGELOG for 4.4.7 [Validator] Fixed calling getters before resolving groups [HttpKernel][LoggerDataCollector] Prevent keys collisions in the sanitized logs processing
2 parents 09dcbfc + e1a522b commit 9a4a969
Copy full SHA for 9a4a969

File tree

Expand file treeCollapse file tree

18 files changed

+187
-15
lines changed
Filter options
Expand file treeCollapse file tree

18 files changed

+187
-15
lines changed

‎CHANGELOG-4.4.md

Copy file name to clipboardExpand all lines: CHANGELOG-4.4.md
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ in 4.4 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/v4.4.0...v4.4.1
99

10+
* 4.4.7 (2020-03-30)
11+
12+
* security #cve-2020-5255 [HttpFoundation] Do not set the default Content-Type based on the Accept header (yceruto)
13+
* security #cve-2020-5275 [Security] Fix access_control behavior with unanimous decision strategy (chalasr)
14+
* bug #36262 [DI] fix generating TypedReference from PriorityTaggedServiceTrait (nicolas-grekas)
15+
* bug #36252 [Security/Http] Allow setting cookie security settings for delete_cookies (wouterj)
16+
* bug #36261 [FrameworkBundle] revert to legacy wiring of the session when circular refs are detected (nicolas-grekas)
17+
* bug #36259 [DomCrawler] Fix BC break in assertions breaking Panther (dunglas)
18+
* bug #36181 [BrowserKit] fixed missing post request parameters in file uploads (codebay)
19+
* bug #36216 [Validator] Assert Valid with many groups (phucwan91)
20+
* bug #36222 [Console] Fix OutputStream for PHP 7.4 (guillbdx)
21+
1022
* 4.4.6 (2020-03-27)
1123

1224
* bug #36169 [HttpKernel] fix locking for PHP 7.4+ (nicolas-grekas)

‎CHANGELOG-5.0.md

Copy file name to clipboardExpand all lines: CHANGELOG-5.0.md
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ in 5.0 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/v5.0.0...v5.0.1
99

10+
* 5.0.7 (2020-03-30)
11+
12+
* security #cve-2020-5255 [HttpFoundation] Do not set the default Content-Type based on the Accept header (yceruto)
13+
* security #cve-2020-5275 [Security] Fix access_control behavior with unanimous decision strategy (chalasr)
14+
* bug #36262 [DI] fix generating TypedReference from PriorityTaggedServiceTrait (nicolas-grekas)
15+
* bug #36252 [Security/Http] Allow setting cookie security settings for delete_cookies (wouterj)
16+
* bug #36261 [FrameworkBundle] revert to legacy wiring of the session when circular refs are detected (nicolas-grekas)
17+
* bug #36259 [DomCrawler] Fix BC break in assertions breaking Panther (dunglas)
18+
* bug #36181 [BrowserKit] fixed missing post request parameters in file uploads (codebay)
19+
* bug #36216 [Validator] Assert Valid with many groups (phucwan91)
20+
* bug #36222 [Console] Fix OutputStream for PHP 7.4 (guillbdx)
21+
1022
* 5.0.6 (2020-03-27)
1123

1224
* bug #36169 [HttpKernel] fix locking for PHP 7.4+ (nicolas-grekas)

‎src/Symfony/Bridge/Twig/Command/LintCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Command/LintCommand.php
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
103103
$prevErrorHandler = set_error_handler(static function ($level, $message, $file, $line) use (&$prevErrorHandler) {
104104
if (E_USER_DEPRECATED === $level) {
105105
$templateLine = 0;
106-
if (preg_match('/ at line (\d+) /', $message, $matches)) {
106+
if (preg_match('/ at line (\d+)[ .]/', $message, $matches)) {
107107
$templateLine = $matches[1];
108108
}
109109

@@ -229,6 +229,14 @@ private function renderException(OutputInterface $output, string $template, Erro
229229
$output->text(sprintf('<error> ERROR </error> (line %s)', $line));
230230
}
231231

232+
// If the line is not known (this might happen for deprecations if we fail at detecting the line for instance),
233+
// we render the message without context, to ensure the message is displayed.
234+
if ($line <= 0) {
235+
$output->text(sprintf('<error> >> %s</error> ', $exception->getRawMessage()));
236+
237+
return;
238+
}
239+
232240
foreach ($this->getContext($template, $line) as $lineNumber => $code) {
233241
$output->text(sprintf(
234242
'%s %-6s %s',

‎src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php
+38-1Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Console\Tester\CommandTester;
1919
use Twig\Environment;
2020
use Twig\Loader\FilesystemLoader;
21+
use Twig\TwigFilter;
2122

2223
class LintCommandTest extends TestCase
2324
{
@@ -66,6 +67,37 @@ public function testLintFileCompileTimeException()
6667
$this->assertRegExp('/ERROR in \S+ \(line /', trim($tester->getDisplay()));
6768
}
6869

70+
/**
71+
* When deprecations are not reported by the command, the testsuite reporter will catch them so we need to mark the test as legacy.
72+
*
73+
* @group legacy
74+
*/
75+
public function testLintFileWithNotReportedDeprecation()
76+
{
77+
$tester = $this->createCommandTester();
78+
$filename = $this->createFile('{{ foo|deprecated_filter }}');
79+
80+
$ret = $tester->execute(['filename' => [$filename]], ['verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false]);
81+
82+
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
83+
$this->assertStringContainsString('OK in', trim($tester->getDisplay()));
84+
}
85+
86+
public function testLintFileWithReportedDeprecation()
87+
{
88+
$tester = $this->createCommandTester();
89+
$filename = $this->createFile('{{ foo|deprecated_filter }}');
90+
91+
$ret = $tester->execute(['filename' => [$filename], '--show-deprecations' => true], ['verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false]);
92+
93+
$this->assertEquals(1, $ret, 'Returns 1 in case of error');
94+
$this->assertRegExp('/ERROR in \S+ \(line 1\)/', trim($tester->getDisplay()));
95+
$this->assertStringContainsString('Filter "deprecated_filter" is deprecated', trim($tester->getDisplay()));
96+
}
97+
98+
/**
99+
* @group tty
100+
*/
69101
public function testLintDefaultPaths()
70102
{
71103
$tester = $this->createCommandTester();
@@ -77,7 +109,12 @@ public function testLintDefaultPaths()
77109

78110
private function createCommandTester(): CommandTester
79111
{
80-
$command = new LintCommand(new Environment(new FilesystemLoader(\dirname(__DIR__).'/Fixtures/templates/')));
112+
$environment = new Environment(new FilesystemLoader(\dirname(__DIR__).'/Fixtures/templates/'));
113+
$environment->addFilter(new TwigFilter('deprecated_filter', function ($v) {
114+
return $v;
115+
}, ['deprecated' => true]));
116+
117+
$command = new LintCommand($environment);
81118

82119
$application = new Application();
83120
$application->add($command);

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/src/CustomPathBundle.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/CustomPathBundle/src/CustomPathBundle.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Bundle\FrameworkBundle\Tests;
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Fixtures\CustomPathBundle;
1313

1414
use Symfony\Component\HttpKernel\Bundle\Bundle;
1515

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/TestBundle.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/TestBundle.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Bundle\FrameworkBundle\Tests;
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Fixtures\TestBundle;
1313

1414
use Symfony\Component\HttpKernel\Bundle\Bundle;
1515

‎src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ private function sanitizeLogs(array $logs)
177177
continue;
178178
}
179179

180-
$message = $log['message'];
180+
$message = '_'.$log['message'];
181181
$exception = $log['context']['exception'];
182182

183183
if ($exception instanceof SilencedErrorContext) {

‎src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,15 @@ public function getCollectTestData()
176176
[
177177
['message' => 'foo3', 'context' => ['exception' => new \ErrorException('warning', 0, E_USER_WARNING)], 'priority' => 100, 'priorityName' => 'DEBUG'],
178178
['message' => 'foo3', 'context' => ['exception' => new SilencedErrorContext(E_USER_WARNING, __FILE__, __LINE__)], 'priority' => 100, 'priorityName' => 'DEBUG'],
179+
['message' => '0', 'context' => ['exception' => new SilencedErrorContext(E_USER_WARNING, __FILE__, __LINE__)], 'priority' => 100, 'priorityName' => 'DEBUG'],
179180
],
180181
[
181182
['message' => 'foo3', 'context' => ['exception' => ['warning', E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG'],
182183
['message' => 'foo3', 'context' => ['exception' => [E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => true],
184+
['message' => '0', 'context' => ['exception' => [E_USER_WARNING]], 'priority' => 100, 'priorityName' => 'DEBUG', 'errorCount' => 1, 'scream' => true],
183185
],
184186
0,
185-
1,
187+
2,
186188
];
187189
}
188190
}

‎src/Symfony/Component/Messenger/Tests/Transport/Receiver/SingleMessageReceiverTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Tests/Transport/Receiver/SingleMessageReceiverTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Messenger\Tests\Transport\Sender;
12+
namespace Symfony\Component\Messenger\Tests\Transport\Receiver;
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Messenger\Envelope;

‎src/Symfony/Component/Messenger/Tests/Transport/Sync/SyncTransportFactoryTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Tests/Transport/Sync/SyncTransportFactoryTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Messenger\Tests\Transport\AmqpExt;
12+
namespace Symfony\Component\Messenger\Tests\Transport\Sync;
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Messenger\MessageBusInterface;

‎src/Symfony/Component/Messenger/Tests/Transport/Sync/SyncTransportTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Tests/Transport/Sync/SyncTransportTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Messenger\Tests\Transport\AmqpExt;
12+
namespace Symfony\Component\Messenger\Tests\Transport\Sync;
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Messenger\Envelope;

‎src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\PropertyInfo\Tests\PhpDocExtractor;
12+
namespace Symfony\Component\PropertyInfo\Tests\Extractor;
1313

1414
use phpDocumentor\Reflection\Types\Collection;
1515
use PHPUnit\Framework\TestCase;

‎src/Symfony/Component/Security/Core/Authorization/TraceableAccessDecisionManager.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Authorization/TraceableAccessDecisionManager.php
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ public function __construct(AccessDecisionManagerInterface $manager)
4747

4848
/**
4949
* {@inheritdoc}
50+
*
51+
* @param bool $allowMultipleAttributes Whether to allow passing multiple values to the $attributes array
5052
*/
51-
public function decide(TokenInterface $token, array $attributes, $object = null): bool
53+
public function decide(TokenInterface $token, array $attributes, $object = null/*, bool $allowMultipleAttributes = false*/): bool
5254
{
5355
$currentDecisionLog = [
5456
'attributes' => $attributes,
@@ -58,7 +60,7 @@ public function decide(TokenInterface $token, array $attributes, $object = null)
5860

5961
$this->currentLog[] = &$currentDecisionLog;
6062

61-
$result = $this->manager->decide($token, $attributes, $object);
63+
$result = $this->manager->decide($token, $attributes, $object, 3 < \func_num_args() && func_get_arg(3));
6264

6365
$currentDecisionLog['result'] = $result;
6466

‎src/Symfony/Component/Validator/Context/ExecutionContext.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Context/ExecutionContext.php
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Symfony\Component\Validator\Mapping\MetadataInterface;
2121
use Symfony\Component\Validator\Mapping\PropertyMetadataInterface;
2222
use Symfony\Component\Validator\Util\PropertyPath;
23+
use Symfony\Component\Validator\Validator\LazyProperty;
2324
use Symfony\Component\Validator\Validator\ValidatorInterface;
2425
use Symfony\Component\Validator\Violation\ConstraintViolationBuilder;
2526
use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface;
@@ -180,7 +181,7 @@ public function addViolation(string $message, array $parameters = [])
180181
$parameters,
181182
$this->root,
182183
$this->propertyPath,
183-
$this->value,
184+
$this->getValue(),
184185
null,
185186
null,
186187
$this->constraint
@@ -199,7 +200,7 @@ public function buildViolation(string $message, array $parameters = []): Constra
199200
$parameters,
200201
$this->root,
201202
$this->propertyPath,
202-
$this->value,
203+
$this->getValue(),
203204
$this->translator,
204205
$this->translationDomain
205206
);
@@ -234,6 +235,10 @@ public function getRoot()
234235
*/
235236
public function getValue()
236237
{
238+
if ($this->value instanceof LazyProperty) {
239+
return $this->value->getPropertyValue();
240+
}
241+
237242
return $this->value;
238243
}
239244

+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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\Validator\Tests\Fixtures;
13+
14+
class EntityWithGroupedConstraintOnMethods
15+
{
16+
public $bar;
17+
18+
public function isValidInFoo()
19+
{
20+
return false;
21+
}
22+
23+
public function getBar()
24+
{
25+
throw new \Exception('Should not be called');
26+
}
27+
}

‎src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,19 @@
1414
use Symfony\Component\Translation\IdentityTranslator;
1515
use Symfony\Component\Validator\Constraints\All;
1616
use Symfony\Component\Validator\Constraints\Collection;
17+
use Symfony\Component\Validator\Constraints\GroupSequence;
18+
use Symfony\Component\Validator\Constraints\IsTrue;
1719
use Symfony\Component\Validator\Constraints\Length;
1820
use Symfony\Component\Validator\Constraints\NotBlank;
21+
use Symfony\Component\Validator\Constraints\NotNull;
1922
use Symfony\Component\Validator\ConstraintValidatorFactory;
2023
use Symfony\Component\Validator\Context\ExecutionContextFactory;
24+
use Symfony\Component\Validator\Mapping\ClassMetadata;
2125
use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface;
2226
use Symfony\Component\Validator\Tests\Constraints\Fixtures\ChildA;
2327
use Symfony\Component\Validator\Tests\Constraints\Fixtures\ChildB;
2428
use Symfony\Component\Validator\Tests\Fixtures\Entity;
29+
use Symfony\Component\Validator\Tests\Fixtures\EntityWithGroupedConstraintOnMethods;
2530
use Symfony\Component\Validator\Validator\RecursiveValidator;
2631
use Symfony\Component\Validator\Validator\ValidatorInterface;
2732

@@ -118,6 +123,25 @@ public function testCollectionConstraintValidateAllGroupsForNestedConstraints()
118123
$this->assertInstanceOf(NotBlank::class, $violations->get(1)->getConstraint());
119124
}
120125

126+
public function testGroupedMethodConstraintValidateInSequence()
127+
{
128+
$metadata = new ClassMetadata(EntityWithGroupedConstraintOnMethods::class);
129+
$metadata->addPropertyConstraint('bar', new NotNull(['groups' => 'Foo']));
130+
$metadata->addGetterMethodConstraint('validInFoo', 'isValidInFoo', new IsTrue(['groups' => 'Foo']));
131+
$metadata->addGetterMethodConstraint('bar', 'getBar', new NotNull(['groups' => 'Bar']));
132+
133+
$this->metadataFactory->addMetadata($metadata);
134+
135+
$entity = new EntityWithGroupedConstraintOnMethods();
136+
$groups = new GroupSequence(['EntityWithGroupedConstraintOnMethods', 'Foo', 'Bar']);
137+
138+
$violations = $this->validator->validate($entity, null, $groups);
139+
140+
$this->assertCount(2, $violations);
141+
$this->assertInstanceOf(NotNull::class, $violations->get(0)->getConstraint());
142+
$this->assertInstanceOf(IsTrue::class, $violations->get(1)->getConstraint());
143+
}
144+
121145
public function testAllConstraintValidateAllGroupsForNestedConstraints()
122146
{
123147
$this->metadata->addPropertyConstraint('data', new All(['constraints' => [
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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\Validator\Validator;
13+
14+
/**
15+
* A wrapper for a callable initializing a property from a getter.
16+
*
17+
* @internal
18+
*/
19+
class LazyProperty
20+
{
21+
private $propertyValueCallback;
22+
23+
public function __construct(\Closure $propertyValueCallback)
24+
{
25+
$this->propertyValueCallback = $propertyValueCallback;
26+
}
27+
28+
public function getPropertyValue()
29+
{
30+
return \call_user_func($this->propertyValueCallback);
31+
}
32+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.