Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 155cfb2

Browse files
Merge branch '4.4'
* 4.4: (33 commits) [DI] fix processing of regular parameter bags by MergeExtensionConfigurationPass [FrameworkBundle] reset cache pools between requests [HttpFoundation] Accept must take the lead for Request::getPreferredFormat() [FrameworkBundle] Allow to use the BrowserKit assertions with Panther and API Platform's test client Use ConnectionRegistry instead of RegistryInterface. Fixes windows error Improving the request/response format autodetection [Messager] Simplified MessageBus::__construct() [WIP][Mailer] Overwrite envelope sender and recipients from config [Messenger] Added more test for MessageBus [Mime] Updated some PHPDoc contents [PropertyAccess] Adds entries to CHANGELOG and UPGRADE fixed typo [FrameworkBundle] Simplified some code in the DI configuration [Filesystem] added missing deprecations to UPGRADE-4.3.md [Filesystem] depreacte calling isAbsolutePath with a null Fix authentication for redis transport only decorate when an event dispatcher was passed [Messenger] Added support for auto trimming of redis streams [FrmaeworkBundle] More simplifications in the DI configuration ...
2 parents fa727be + b9b03fe commit 155cfb2

File tree

68 files changed

+887
-354
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+887
-354
lines changed

UPGRADE-4.3.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ EventDispatcher
5757
* The signature of the `EventDispatcherInterface::dispatch()` method should be updated to `dispatch($event, string $eventName = null)`, not doing so is deprecated
5858
* The `Event` class has been deprecated, use `Symfony\Contracts\EventDispatcher\Event` instead
5959

60+
Filesystem
61+
----------
62+
63+
* Support for passing arrays to `Filesystem::dumpFile()` is deprecated.
64+
* Support for passing arrays to `Filesystem::appendToFile()` is deprecated.
65+
6066
Form
6167
----
6268

@@ -71,6 +77,7 @@ Form
7177
FrameworkBundle
7278
---------------
7379

80+
* Deprecated the `framework.templating` option, use Twig instead.
7481
* Not passing the project directory to the constructor of the `AssetsInstallCommand` is deprecated. This argument will
7582
be mandatory in 5.0.
7683
* Deprecated the "Psr\SimpleCache\CacheInterface" / "cache.app.simple" service, use "Symfony\Contracts\Cache\CacheInterface" / "cache.app" instead.

UPGRADE-4.4.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ DependencyInjection
2626
services:
2727
App\Handler:
2828
tags: ['app.handler']
29-
29+
3030
App\HandlerCollection:
3131
arguments: [!tagged app.handler]
3232
```
@@ -36,11 +36,16 @@ DependencyInjection
3636
services:
3737
App\Handler:
3838
tags: ['app.handler']
39-
39+
4040
App\HandlerCollection:
4141
arguments: [!tagged_iterator app.handler]
4242
```
4343

44+
Filesystem
45+
----------
46+
47+
* Support for passing a `null` value to `Filesystem::isAbsolutePath()` is deprecated.
48+
4449
Form
4550
----
4651

@@ -60,6 +65,11 @@ HttpClient
6065

6166
* Added method `cancel()` to `ResponseInterface`
6267

68+
HttpFoundation
69+
--------------
70+
71+
* `ApacheRequest` is deprecated, use `Request` class instead.
72+
6373
HttpKernel
6474
----------
6575

@@ -76,6 +86,11 @@ MonologBridge
7686

7787
* The `RouteProcessor` has been marked final.
7888

89+
PropertyAccess
90+
--------------
91+
92+
* Deprecated passing `null` as 2nd argument of `PropertyAccessor::createCache()` method (`$defaultLifetime`), pass `0` instead.
93+
7994
Security
8095
--------
8196

@@ -84,11 +99,19 @@ Security
8499
TwigBridge
85100
----------
86101

87-
* Deprecated to pass `$rootDir` and `$fileLinkFormatter` as 5th and 6th argument respectively to the
102+
* Deprecated to pass `$rootDir` and `$fileLinkFormatter` as 5th and 6th argument respectively to the
88103
`DebugCommand::__construct()` method, swap the variables position.
89104

90105
Validator
91106
---------
92107

108+
* Deprecated passing an `ExpressionLanguage` instance as the second argument of `ExpressionValidator::__construct()`.
109+
* Deprecated using anything else than a `string` as the code of a `ConstraintViolation`, a `string` type-hint will
110+
be added to the constructor of the `ConstraintViolation` class and to the `ConstraintViolationBuilder::setCode()`
111+
method in 5.0.
93112
* Deprecated passing an `ExpressionLanguage` instance as the second argument of `ExpressionValidator::__construct()`.
94113
Pass it as the first argument instead.
114+
* The `Length` constraint expects the `allowEmptyString` option to be defined
115+
when the `min` option is used.
116+
Set it to `true` to keep the current behavior and `false` to reject empty strings.
117+
In 5.0, it'll become optional and will default to `false`.

UPGRADE-5.0.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ DependencyInjection
101101
services:
102102
App\Handler:
103103
tags: ['app.handler']
104-
104+
105105
App\HandlerCollection:
106106
arguments: [!tagged_iterator app.handler]
107107
```
@@ -114,7 +114,6 @@ DoctrineBridge
114114
* Passing an `IdReader` to the `DoctrineChoiceLoader` when the query cannot be optimized with single id field will throw an exception, pass `null` instead
115115
* Not passing an `IdReader` to the `DoctrineChoiceLoader` when the query can be optimized with single id field will not apply any optimization
116116

117-
118117
DomCrawler
119118
----------
120119

@@ -135,6 +134,7 @@ EventDispatcher
135134
Filesystem
136135
----------
137136

137+
* The `Filesystem::isAbsolutePath()` method no longer supports `null` in the `$file` argument.
138138
* The `Filesystem::dumpFile()` method no longer supports arrays in the `$content` argument.
139139
* The `Filesystem::appendToFile()` method no longer supports arrays in the `$content` argument.
140140

@@ -207,8 +207,8 @@ Form
207207
FrameworkBundle
208208
---------------
209209

210+
* Removed the `framework.templating` option, use Twig instead.
210211
* The project dir argument of the constructor of `AssetsInstallCommand` is required.
211-
212212
* Removed support for `bundle:controller:action` syntax to reference controllers. Use `serviceOrFqcn::method`
213213
instead where `serviceOrFqcn` is either the service ID when using controllers as services or the FQCN of the controller.
214214

@@ -269,6 +269,7 @@ HttpFoundation
269269
use `Symfony\Component\Mime\FileBinaryMimeTypeGuesser` instead.
270270
* The `FileinfoMimeTypeGuesser` class has been removed,
271271
use `Symfony\Component\Mime\FileinfoMimeTypeGuesser` instead.
272+
* `ApacheRequest` has been removed, use the `Request` class instead.
272273

273274
HttpKernel
274275
----------
@@ -476,6 +477,8 @@ TwigBridge
476477
Validator
477478
--------
478479

480+
* Removed support for non-string codes of a `ConstraintViolation`. A `string` type-hint was added to the constructor of
481+
the `ConstraintViolation` class and to the `ConstraintViolationBuilder::setCode()` method.
479482
* An `ExpressionLanguage` instance or null must be passed as the first argument of `ExpressionValidator::__construct()`
480483
* The `checkMX` and `checkHost` options of the `Email` constraint were removed
481484
* The `Email::__construct()` 'strict' property has been removed. Use 'mode'=>"strict" instead.
@@ -540,7 +543,6 @@ Workflow
540543
property: state
541544
```
542545

543-
544546
* Support for using a workflow with a single state marking is dropped. Use a state machine instead.
545547

546548
Before:

src/Symfony/Bridge/Doctrine/Tests/Fixtures/BaseUser.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace Symfony\Bridge\Doctrine\Tests\Fixtures;
44

5+
use Symfony\Component\Validator\Constraints as Assert;
6+
use Symfony\Component\Validator\Mapping\ClassMetadata;
7+
58
/**
69
* Class BaseUser.
710
*/
@@ -46,4 +49,15 @@ public function getUsername()
4649
{
4750
return $this->username;
4851
}
52+
53+
public static function loadValidatorMetadata(ClassMetadata $metadata): void
54+
{
55+
$allowEmptyString = property_exists(Assert\Length::class, 'allowEmptyString') ? ['allowEmptyString' => true] : [];
56+
57+
$metadata->addPropertyConstraint('username', new Assert\Length([
58+
'min' => 2,
59+
'max' => 120,
60+
'groups' => ['Registration'],
61+
] + $allowEmptyString));
62+
}
4963
}

src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderEntity.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\ORM\Mapping as ORM;
1515
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
1616
use Symfony\Component\Validator\Constraints as Assert;
17+
use Symfony\Component\Validator\Mapping\ClassMetadata;
1718

1819
/**
1920
* @ORM\Entity
@@ -36,13 +37,11 @@ class DoctrineLoaderEntity extends DoctrineLoaderParentEntity
3637

3738
/**
3839
* @ORM\Column(length=20)
39-
* @Assert\Length(min=5)
4040
*/
4141
public $mergedMaxLength;
4242

4343
/**
4444
* @ORM\Column(length=20)
45-
* @Assert\Length(min=1, max=10)
4645
*/
4746
public $alreadyMappedMaxLength;
4847

@@ -69,4 +68,12 @@ class DoctrineLoaderEntity extends DoctrineLoaderParentEntity
6968

7069
/** @ORM\Column(type="simple_array", length=100) */
7170
public $simpleArrayField = [];
71+
72+
public static function loadValidatorMetadata(ClassMetadata $metadata): void
73+
{
74+
$allowEmptyString = property_exists(Assert\Length::class, 'allowEmptyString') ? ['allowEmptyString' => true] : [];
75+
76+
$metadata->addPropertyConstraint('mergedMaxLength', new Assert\Length(['min' => 5] + $allowEmptyString));
77+
$metadata->addPropertyConstraint('alreadyMappedMaxLength', new Assert\Length(['min' => 1, 'max' => 10] + $allowEmptyString));
78+
}
7279
}

src/Symfony/Bridge/Doctrine/Tests/Resources/validator/BaseUser.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
<constraint name="NotBlank">
1010
<option name="groups">Registration</option>
1111
</constraint>
12-
<constraint name="Length">
13-
<option name="min">2</option>
14-
<option name="max">120</option>
15-
<option name="groups">Registration</option>
16-
</constraint>
1712
</property>
1813
</class>
1914
</constraint-mapping>

src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function testLoadClassMetadata()
4040
}
4141

4242
$validator = Validation::createValidatorBuilder()
43+
->addMethodMapping('loadValidatorMetadata')
4344
->enableAnnotationMapping()
4445
->addLoader(new DoctrineLoader(DoctrineTestHelper::createTestEntityManager(), '{^Symfony\\\\Bridge\\\\Doctrine\\\\Tests\\\\Fixtures\\\\DoctrineLoader}'))
4546
->getValidator()
@@ -142,6 +143,7 @@ public function testFieldMappingsConfiguration()
142143
}
143144

144145
$validator = Validation::createValidatorBuilder()
146+
->addMethodMapping('loadValidatorMetadata')
145147
->enableAnnotationMapping()
146148
->addXmlMappings([__DIR__.'/../Resources/validator/BaseUser.xml'])
147149
->addLoader(

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
$prevRoot = getenv('COMPOSER_ROOT_VERSION');
132132
putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99");
133133
// --no-suggest is not in the list to keep compat with composer 1.0, which is shipped with Ubuntu 16.04LTS
134-
$exit = proc_close(proc_open("$COMPOSER install --no-dev --prefer-dist --no-progress --ansi", array(), $p, getcwd(), null, array('bypass_shell' => true)));
134+
$exit = proc_close(proc_open("$COMPOSER install --no-dev --prefer-dist --no-progress --ansi", array(), $p));
135135
putenv('COMPOSER_ROOT_VERSION'.(false !== $prevRoot ? '='.$prevRoot : ''));
136136
if ($exit) {
137137
exit($exit);

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ CHANGELOG
2929
4.3.0
3030
-----
3131

32+
* Deprecated the `framework.templating` option, use Twig instead.
3233
* Added `WebTestAssertionsTrait` (included by default in `WebTestCase`)
3334
* Renamed `Client` to `KernelBrowser`
3435
* Not passing the project directory to the constructor of the `AssetsInstallCommand` is deprecated. This argument will

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
297297
->cannotBeEmpty()
298298
->end()
299299
->arrayNode('initial_marking')
300-
->beforeNormalization()
301-
->ifTrue(function ($v) { return !\is_array($v); })
302-
->then(function ($v) { return [$v]; })
303-
->end()
300+
->beforeNormalization()->castToArray()->end()
304301
->defaultValue([])
305302
->prototype('scalar')->end()
306303
->end()
@@ -533,10 +530,7 @@ private function addRequestSection(ArrayNodeDefinition $rootNode)
533530
->ifTrue(function ($v) { return \is_array($v) && isset($v['mime_type']); })
534531
->then(function ($v) { return $v['mime_type']; })
535532
->end()
536-
->beforeNormalization()
537-
->ifTrue(function ($v) { return !\is_array($v); })
538-
->then(function ($v) { return [$v]; })
539-
->end()
533+
->beforeNormalization()->castToArray()->end()
540534
->prototype('scalar')->end()
541535
->end()
542536
->end()
@@ -562,10 +556,7 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode)
562556
->scalarNode('base_path')->defaultValue('')->end()
563557
->arrayNode('base_urls')
564558
->requiresAtLeastOneElement()
565-
->beforeNormalization()
566-
->ifTrue(function ($v) { return !\is_array($v); })
567-
->then(function ($v) { return [$v]; })
568-
->end()
559+
->beforeNormalization()->castToArray()->end()
569560
->prototype('scalar')->end()
570561
->end()
571562
->end()
@@ -607,10 +598,7 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode)
607598
->scalarNode('base_path')->defaultValue('')->end()
608599
->arrayNode('base_urls')
609600
->requiresAtLeastOneElement()
610-
->beforeNormalization()
611-
->ifTrue(function ($v) { return !\is_array($v); })
612-
->then(function ($v) { return [$v]; })
613-
->end()
601+
->beforeNormalization()->castToArray()->end()
614602
->prototype('scalar')->end()
615603
->end()
616604
->end()
@@ -684,10 +672,7 @@ private function addValidationSection(ArrayNodeDefinition $rootNode)
684672
->defaultValue(['loadValidatorMetadata'])
685673
->prototype('scalar')->end()
686674
->treatFalseLike([])
687-
->validate()
688-
->ifTrue(function ($v) { return !\is_array($v); })
689-
->then(function ($v) { return (array) $v; })
690-
->end()
675+
->validate()->castToArray()->end()
691676
->end()
692677
->scalarNode('translation_domain')->defaultValue('validators')->end()
693678
->enumNode('email_validation_mode')->values(['html5', 'loose', 'strict'])->end()
@@ -1061,9 +1046,14 @@ function ($a) {
10611046
->end()
10621047
->arrayNode('retry_strategy')
10631048
->addDefaultsIfNotSet()
1064-
->validate()
1065-
->ifTrue(function ($v) { return null !== $v['service'] && (isset($v['max_retries']) || isset($v['delay']) || isset($v['multiplier']) || isset($v['max_delay'])); })
1066-
->thenInvalid('"service" cannot be used along with the other retry_strategy options.')
1049+
->beforeNormalization()
1050+
->always(function ($v) {
1051+
if (isset($v['service']) && (isset($v['max_retries']) || isset($v['delay']) || isset($v['multiplier']) || isset($v['max_delay']))) {
1052+
throw new \InvalidArgumentException('The "service" cannot be used along with the other "retry_strategy" options.');
1053+
}
1054+
1055+
return $v;
1056+
})
10671057
->end()
10681058
->children()
10691059
->scalarNode('service')->defaultNull()->info('Service id to override the retry strategy entirely')->end()
@@ -1280,6 +1270,9 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode)
12801270
->scalarNode('auth_bearer')
12811271
->info('A token enabling HTTP Bearer authorization.')
12821272
->end()
1273+
->scalarNode('auth_ntlm')
1274+
->info('A "username:password" pair to use Microsoft NTLM authentication (requires the cURL extension).')
1275+
->end()
12831276
->arrayNode('query')
12841277
->info('Associative array of query string values merged with the base URI.')
12851278
->useAttributeAsKey('key')
@@ -1391,6 +1384,22 @@ private function addMailerSection(ArrayNodeDefinition $rootNode)
13911384
->{!class_exists(FullStack::class) && class_exists(Mailer::class) ? 'canBeDisabled' : 'canBeEnabled'}()
13921385
->children()
13931386
->scalarNode('dsn')->defaultValue('smtp://null')->end()
1387+
->arrayNode('envelope')
1388+
->info('Mailer Envelope configuration')
1389+
->children()
1390+
->scalarNode('sender')->end()
1391+
->arrayNode('recipients')
1392+
->performNoDeepMerging()
1393+
->beforeNormalization()
1394+
->ifArray()
1395+
->then(function ($v) {
1396+
return array_filter(array_values($v));
1397+
})
1398+
->end()
1399+
->prototype('scalar')->end()
1400+
->end()
1401+
->end()
1402+
->end()
13941403
->end()
13951404
->end()
13961405
->end()

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,6 +1763,13 @@ private function registerMailerConfiguration(array $config, ContainerBuilder $co
17631763

17641764
$loader->load('mailer.xml');
17651765
$container->getDefinition('mailer.default_transport')->setArgument(0, $config['dsn']);
1766+
1767+
$recipients = $config['envelope']['recipients'] ?? null;
1768+
$sender = $config['envelope']['sender'] ?? null;
1769+
1770+
$envelopeListener = $container->getDefinition('mailer.envelope_listener');
1771+
$envelopeListener->setArgument(0, $sender);
1772+
$envelopeListener->setArgument(1, $recipients);
17661773
}
17671774

17681775
/**

0 commit comments

Comments
 (0)