Commit Graph

51429 Commits

Author SHA1 Message Date
Nicolas Grekas
746a8d1a09 [DI] fix dumping env vars 2020-10-13 11:53:00 +02:00
Nicolas Grekas
f52f090230 feature #38532 [HttpClient] simplify retry mechanism around RetryStrategyInterface (nicolas-grekas)
This PR was merged into the 5.x branch.

Discussion
----------

[HttpClient] simplify retry mechanism around RetryStrategyInterface

| Q             | A
| ------------- | ---
| Branch?       | 5.2
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Replaces #38466

I feel like the mechanism behind RetryableHttpClient is too bloated for no pragmatic reasons.

I propose to merge RetryDeciderInterface and RetryBackoffInterface into one single RetryStrategyInterface.

Having two separate interfaces supports no real-world use case. The only implementations we provide are trivial, and they can be reused by extending the provided GenericRetryStrategy implementation if one really doesn't want to duplicate that.

The methods are also simplified by accepting an AsyncContext as argument. This makes the signatures shorter and allows accessing the "info" of the request (allowing to decide based on the IP of the host, etc).

/cc @jderusse

Commits
-------

544c3e8678 [HttpClient] simplify retry mechanism around RetryStrategyInterface
2020-10-13 10:09:30 +02:00
Nicolas Grekas
a580688ee5 [HttpClient] skip executing the multi handle when it's freed already 2020-10-13 10:06:18 +02:00
Nicolas Grekas
4f8384829c [HttpClient] fix using freed curl resource at destruct time 2020-10-13 09:54:33 +02:00
Nicolas Grekas
a279d22d25 [HttpClient] shutdown verbose output from curl at destruction 2020-10-13 09:44:15 +02:00
Nicolas Grekas
544c3e8678 [HttpClient] simplify retry mechanism around RetryStrategyInterface 2020-10-13 09:28:31 +02:00
Bernd Stellwag
2a370143a4 fix warning for preloading TranslatorTrait class 2020-10-13 07:04:30 +02:00
Fabien Potencier
ee3294e050 Merge branch '5.1' into 5.x
* 5.1:
  fix warning for preloading TranslatorTrait class
2020-10-13 06:59:45 +02:00
Fabien Potencier
5b9ccde1e0 bug #38533 [TwigBridge] Fix preload hint and remove "unlinked class class@anonymous" warning (burned42)
This PR was merged into the 5.1 branch.

Discussion
----------

[TwigBridge] Fix preload hint and remove "unlinked class class@anonymous" warning

| Q             | A
| ------------- | ---
| Branch?       | 5.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #38197
| License       | MIT
| Doc PR        | n/a

This should fix the preload warning mentioned in https://github.com/symfony/symfony/issues/38197 by applying the fix as suggested by @nicolas-grekas:

```
PHP Warning:  Can't preload unlinked class class@anonymous: Unknown trait Symfony\\Contracts\\Translation\\TranslatorTrait in /var/www/html/vendor/symfony/twig-bridge/Extension/TranslationExtension.php on line 50
```

Commits
-------

0f167f6ed4 fix warning for preloading TranslatorTrait class
2020-10-13 06:57:42 +02:00
Nicolas Grekas
9c3a9282f1 Fix CS 2020-10-12 21:59:40 +02:00
Bernd Stellwag
0f167f6ed4 fix warning for preloading TranslatorTrait class 2020-10-12 21:56:01 +02:00
Fabien Potencier
ef1253b7c4 Fix tests 2020-10-12 20:55:37 +02:00
Fabien Potencier
14d0fcf162 bug #38528 [Security] Making login link signature_properties option required (weaverryan)
This PR was merged into the 5.x branch.

Discussion
----------

[Security] Making login link signature_properties option required

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | yes (for a 5.2 feature)
| New feature?  | no
| Deprecations? | no
| Tickets       | none
| License       | MIT
| Doc PR        | not needed

Hi!

My intention was always to force the user to set this option. Before this PR, you can simply leave this option off completely without a validation error. Thanks to Wouter for finding it.

Also: made some punctuation & capitalization consistent on info messages.

Cheers!

Commits
-------

f7bb954979 Making login link signature_properties option required
2020-10-12 20:49:27 +02:00
Fabien Potencier
a319090109 feature #38525 [Serializer] Enabled mapping configuration via attributes (derrabus)
This PR was merged into the 5.x branch.

Discussion
----------

[Serializer] Enabled mapping configuration via attributes

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | N/A
| License       | MIT
| Doc PR        | TODO

Let's use attributes for the serializer mapping configuration!

```php
class MyEntity
{
    #[Groups(['list', 'detail])]
    #[SerializedName('some-property')]
    public $someProperty;

    #[Ignore]
    public string $secret;
}
```

Commits
-------

cfb9986203 [Serializer] Enabled mapping configuration via attributes.
2020-10-12 20:19:00 +02:00
Fabien Potencier
1d9c7a9376 Fix composer.json 2020-10-12 20:08:13 +02:00
Fabien Potencier
4b6e656ae2 feature #38522 [Notifier ] Add Discord notifier (mpiot, connorhu)
This PR was merged into the 5.x branch.

Discussion
----------

[Notifier ] Add Discord notifier

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      |  no
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        | symfony/symfony-docs#13558

It finish the PR #36475

Commits
-------

b9b20d782b Added Discord bridge notifier embeds and test
14790d8140 Add Discord bridge notifier
2020-10-12 20:07:37 +02:00
Karoly Gossler
b9b20d782b Added Discord bridge notifier embeds and test 2020-10-12 20:07:15 +02:00
Mathieu Piot
14790d8140 Add Discord bridge notifier 2020-10-12 20:07:15 +02:00
Fabien Potencier
88b158d989 bug #38477 [Form] fix ViolationMapper was always generating a localized label for each FormType (romaricdrigon)
This PR was merged into the 5.x branch.

Discussion
----------

[Form] fix ViolationMapper was always generating a localized label for each FormType

| Q             | A
| ------------- | ---
| Branch?       | 5.x (fix new behavior from 5.2)
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | /
| License       | MIT
| Doc PR        | /

Follow-up of #38435, with branch changed

**Explanation of the issue**

In Symfony 5.2, the `{{ label }}` placeholder can be used in constraint messages (-> introduced in commit 0d9f44235c)

However, the way it was coded is introducing a small side effect: now, every time there is validation error, `ViolationMapper` will ask the Form Type its `label`, and if not `false`, it will try to translate it.

**Why it is important/why it causes a BC break**

Since by default `AbstractType` does not have any `label`, it also introduces a minor BC break.
I will explain it with an example: in a project I work on, we check we don't have any missing translation. Sometimes we have violation errors bound to form ; then current code will get Form `label`, which in `null` in form type classes (which is quite usual I believe), so it will generate one, and pass that one to translator. And we see a lot on erroneous missing translations.

**Proposed fix**

This fix moves all this logic into a `if`, so `ViolationMapper` call the translator component only if `{{ label }}` placeholder is used in constraint error message.
On top of fixing BC, it has the benefit of lowering the performance cost for every violation when the feature is not used.

I added a test, as I believe the behavior should be guaranteed from now on.

Commits
-------

aee5571a71 [Form] fix ViolationMapper was always generating a localized label for each FormType
2020-10-12 20:01:17 +02:00
Fabien Potencier
19c550db7b bug #38529 [Mailer] Fix mailjet image embedding (Sandldan)
This PR was merged into the 5.x branch.

Discussion
----------

[Mailer] Fix mailjet image embedding

Filename is not enough to embed the image through cid, ContentID field
has to be set with the cid identifier used in the HTMLPart

| Q             | A
| ------------- | ---
| Branch?       | 5.1 <!-- see below -->
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | none <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT
| Doc PR        | not needed <!-- required for new features -->
<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/releases):
 - Always add tests and ensure they pass.
 - Never break backward compatibility (see https://symfony.com/bc).
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too.)
 - Features and deprecations must be submitted against branch 5.x.
-->

Hello!

While switching from `Mandrill` to `Mailjet` I noticed that embedding images was not working properly, the `Content-ID` mime is not set properly without setting the `ContentID` key. With this change things will work as described in the [symfony documentation](https://symfony.com/doc/current/mailer.html#embedding-images)

[Mailjet reference](https://dev.mailjet.com/email/guides/send-api-v31/#send-with-attached-files)

Commits
-------

7ab772eeea [Mailer] Fix mailjet image embedding
2020-10-12 19:58:26 +02:00
Nicolas Grekas
444626bbfc Merge branch '5.1' into 5.x
* 5.1:
  [HttpClient] fix reading the body after a ClientException
  [HttpClient] fix tests and merge
2020-10-12 18:54:56 +02:00
Nicolas Grekas
b9e76b2bd9 Merge branch '4.4' into 5.1
* 4.4:
  [HttpClient] fix reading the body after a ClientException
2020-10-12 18:39:05 +02:00
Nicolas Grekas
36d382e266 bug #38530 [HttpClient] fix reading the body after a ClientException (nicolas-grekas)
This PR was merged into the 4.4 branch.

Discussion
----------

[HttpClient] fix reading the body after a ClientException

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

#38508 wasn't enough to fix the issue.

Commits
-------

0159a39709 [HttpClient] fix reading the body after a ClientException
2020-10-12 18:37:39 +02:00
Nicolas Grekas
0159a39709 [HttpClient] fix reading the body after a ClientException 2020-10-12 18:35:20 +02:00
Nicolas Grekas
481a2917c1 [HttpClient] fix tests and merge 2020-10-12 17:25:56 +02:00
Nicolas Grekas
c31015e456 [HttpClient] fix tests and merge 2020-10-12 17:16:53 +02:00
Andre Johnson
7ab772eeea
[Mailer] Fix mailjet image embedding
Filename is not enough to embed the image through cid, ContentID field
has to be set with the cid identifier used in the HTMLPart
2020-10-12 15:57:02 +02:00
Ryan Weaver
f7bb954979 Making login link signature_properties option required 2020-10-12 09:36:23 -04:00
Nicolas Grekas
8a70d35a5f Merge branch '5.1' into 5.x
* 5.1:
  [Validator] remove phpunit-bridge from dev deps
2020-10-12 14:57:48 +02:00
Nicolas Grekas
d83f806e5f [Validator] remove phpunit-bridge from dev deps 2020-10-12 14:57:15 +02:00
Alexander M. Turek
cfb9986203 [Serializer] Enabled mapping configuration via attributes. 2020-10-12 14:52:41 +02:00
Fabien Potencier
f3e496f56f minor #38521 [Typography] Fix SerializerAwareInterface description (idetox)
This PR was submitted for the 5.x branch but it was merged into the 3.4 branch instead.

Discussion
----------

[Typography] Fix SerializerAwareInterface description

| Q             | A
| ------------- | ---
| Branch?       | 5.x<!-- see below -->
| Bug fix?      | no
| New feature?  | no
| Deprecations? |no
| Tickets       |  -
| License       | MIT

Removed some unneeded comments in Serializer / Normalizer / Encoder directory

Commits
-------

48e6976ac8 [Typography] Remove unneeded description comments
2020-10-12 14:32:48 +02:00
idetox
48e6976ac8 [Typography] Remove unneeded description comments 2020-10-12 14:32:39 +02:00
Nicolas Grekas
6844cb8685 bug #38523 [HttpClient] Fix multiple timeout with multiple retry (jderusse)
This PR was merged into the 5.x branch.

Discussion
----------

[HttpClient] Fix multiple timeout with multiple retry

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | /
| License       | MIT
| Doc PR        | /

Fix #38518 when retryied request also failed.

Commits
-------

79a9392468 Fix multiple timeou with multiple retry
2020-10-12 14:06:18 +02:00
Nicolas Grekas
e4024e80ed Merge branch '5.1' into 5.x
* 5.1:
  Disable the PhpUnit bridge when testing it
  [PropertyInfo] Support for the mixed type.
  Don't unset the inflate resource on close as it might still be needed
  [HttpClient] Fix CurlHttpClient memory leak
  [Form] Add Bosnian (bs) validators translation
  [Form] Add missing Serbian (latn & cyrl) validators translation
  [Cache] skip igbinary < 3.1.6
  [Ldap] Bypass the use of `ldap_control_paged_result` on PHP >= 7.3
  [Form] [Validator] added pt_BR translations
  Estonian update
  Fix no collection in extract default value
  [PhpUnitBridge] fix running parallel tests with phpunit 9
  [VarDumper] fix truncating big arrays
2020-10-12 14:05:07 +02:00
Nicolas Grekas
a1616a76eb Merge branch '4.4' into 5.1
* 4.4:
  Disable the PhpUnit bridge when testing it
  [PropertyInfo] Support for the mixed type.
  Don't unset the inflate resource on close as it might still be needed
  [HttpClient] Fix CurlHttpClient memory leak
  [Form] Add Bosnian (bs) validators translation
  [Form] Add missing Serbian (latn & cyrl) validators translation
  [Cache] skip igbinary < 3.1.6
  [Ldap] Bypass the use of `ldap_control_paged_result` on PHP >= 7.3
  [Form] [Validator] added pt_BR translations
  Estonian update
  [PhpUnitBridge] fix running parallel tests with phpunit 9
  [VarDumper] fix truncating big arrays
2020-10-12 13:21:05 +02:00
Nicolas Grekas
6000e51629 Merge branch '3.4' into 4.4
* 3.4:
  Disable the PhpUnit bridge when testing it
  [PropertyInfo] Support for the mixed type.
  [Form] Add Bosnian (bs) validators translation
  [Form] Add missing Serbian (latn & cyrl) validators translation
  [Form] [Validator] added pt_BR translations
  Estonian update
  [PhpUnitBridge] fix running parallel tests with phpunit 9
  [VarDumper] fix truncating big arrays
2020-10-12 13:11:24 +02:00
Nicolas Grekas
b45f002932 Disable the PhpUnit bridge when testing it 2020-10-12 12:52:41 +02:00
Jérémy Derussé
79a9392468
Fix multiple timeou with multiple retry 2020-10-12 11:08:06 +02:00
Nicolas Grekas
177cd1abce Fix test for PHP 8 2020-10-12 10:22:47 +02:00
Nicolas Grekas
2a70f68847 bug #38520 [HttpClient] Fix nesteed stream in AsyncResponse (jderusse)
This PR was merged into the 5.x branch.

Discussion
----------

[HttpClient] Fix nesteed stream in AsyncResponse

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #38509
| License       | MIT
| Doc PR        | /

When streaming twice (streaming inside streaming) an AsycResponse the second stream will yield the LastChunk, but the first Stream won't have access to it and ends with an exception `A chunk passthru must yield an "isLast()" chunk`
This PR adds a state in AsyncRsponse to remember if the lastChunk has been yielded.

Reproducer:
```php
// a Simple Client that return an AsyncResponse
$client = new class(HttpClient::create()) implements HttpClientInterface {
    use AsyncDecoratorTrait;
    private $client;
    public function __construct(HttpClientInterface $client)
    {
        $this->client = $client;
    }

    public function request(string $method, string $url, array $options = []): ResponseInterface
    {
        return new AsyncResponse($this->client, $method, $url, $options, null);
    }
};

$response = $client->request('GET', 'https://httpbin.org/status/200');

foreach ($client->stream($response) as $chunk) { // will end in a FirstChunk <== bug
    foreach ($client->stream($response) as $chunk) { // This will correctly handle the LastChunk

    }
}

```

Commits
-------

8ba54c17be Fix nesteed stream in AsyncResponse
2020-10-12 09:57:06 +02:00
Jérémy Derussé
8ba54c17be Fix nesteed stream in AsyncResponse 2020-10-12 09:56:41 +02:00
Nicolas Grekas
62d40d5866 bug #38518 [HttpClient] fix decorating timeout errors (nicolas-grekas)
This PR was merged into the 5.x branch.

Discussion
----------

[HttpClient] fix decorating timeout errors

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Replaces #38501
| License       | MIT
| Doc PR        | -

/cc @jderusse

Commits
-------

84cda3f02b [HttpClient] fix decorating timeout errors
2020-10-12 09:54:11 +02:00
Nicolas Grekas
84cda3f02b [HttpClient] fix decorating timeout errors 2020-10-12 09:45:36 +02:00
Nicolas Grekas
a8479e8b31 minor #38508 [HttpClient] Content doesn't get decoded when fetched from an exception (HypeMC)
This PR was merged into the 4.4 branch.

Discussion
----------

[HttpClient] Content doesn't get decoded when fetched from an exception

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

My previous PR #38493 created a new bug, the content doesn't get decoded when fetched from an exception because the inflate resource gets unset:

```php
<?php

use Symfony\Component\HttpClient\CurlHttpClient;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;

include __DIR__.'/symfony/vendor/autoload.php';

$client = new CurlHttpClient();

try {
    $client->request('GET', 'http://example.com/404');
} catch (ClientExceptionInterface $exception) {
    echo $exception->getResponse()->getContent(false);
}
```

I've removed the part where the resource gets unset since it still might be used at some point.

The test is implementation independent so I believe it should go in contracts, please correct me if I wrong. Also, I was unable to find a way to do the test without adding a new endpoint this time, any suggestions would be appreciated.

Commits
-------

8fa4f85013 Don't unset the inflate resource on close as it might still be needed
2020-10-11 10:48:16 +02:00
Fabien Potencier
87920d266e feature #38499 [Validator] Upgraded constraints to enable named arguments and attributes (derrabus)
This PR was squashed before being merged into the 5.x branch.

Discussion
----------

[Validator] Upgraded constraints to enable named arguments and attributes

| Q             | A
| ------------- | ---
| Branch?       | 5.2
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | #38096
| License       | MIT
| Doc PR        | TODO with symfony/symfony-docs#14305

This PR enables all remaining atomic (!= composite) constraints to be used as attributes.

The only exception is `UniqueEntity` from Doctrine bridge because we don't have a Doctrine ORM release yet that supports PHP 8. So I could migrate that one as well, but I cannot really test it.

Commits
-------

fb99eb2052 [Validator] Upgraded constraints to enable named arguments and attributes
2020-10-11 08:04:09 +02:00
Alexander M. Turek
fb99eb2052 [Validator] Upgraded constraints to enable named arguments and attributes 2020-10-11 08:04:04 +02:00
Fabien Potencier
b9d4a2b6f5 feature #38505 [Security][Login Link] Allow null and DateTime objects to be used as signatureProperties (wouterj)
This PR was merged into the 5.x branch.

Discussion
----------

[Security][Login Link] Allow null and DateTime objects to be used as signatureProperties

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Returning `DateTime` objects seems like a common use-case to automatically expire all login links when one is used or to only allow the login link to be used once.

**Before**

```php
class User
{
    private ?\DateTime $lastAuthenticatedAt = null;
    // ...

    public function getLastAuthenticatedAtString(): string
    {
        return null === $this->lastAuthenticatedAt ? '' : $this->lastAuthenticatedAt->format('c');
    }
}
```
```yaml
security:
  firewalls:
    main:
      login_link:
        # ...
        signature_properties: ['lastAuthenticatedAtString']
````

**After**

```php
class User
{
    private ?\DateTime $lastAuthenticatedAt = null;
    // ...

    public function getLastAuthenticatedAt(): ?\DateTime
    {
        return $this->lastAuthenticatedAt;
    }
}
```
```yaml
security:
  firewalls:
    main:
      login_link:
        # ...
        signature_properties: ['lastAuthenticatedAt']
````

---

The disadvantage of this patch is that there needs to be some boundary as to which objects we want to support casting to a scalar, but I'm convinced that `DateTime` objects will commonly be used as signature properties.

cc @weaverryan

Commits
-------

0f947b2e84 Allow null and DateTime objects to be used as signatureProperties
2020-10-11 08:02:30 +02:00
Fabien Potencier
3ec2c8a099 minor #38506 [Security] Add error message when using LoginLinkHandler outside a firewall (wouterj)
This PR was merged into the 5.x branch.

Discussion
----------

[Security] Add error message when using LoginLinkHandler outside a firewall

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Add a more friendly error message when autowiring `LoginLinkHanderInterface` in a route outside the firewall. Current error was `Call to a member function getName() on null`.

Commits
-------

f807b5fc15 Add error message when using LoginLinkHandler outside a firewall
2020-10-11 08:00:10 +02:00
Fabien Potencier
d1f2fafcaa bug #38507 [Bug] Fix RateLimiter framework configuration (bobvandevijver)
This PR was merged into the 5.x branch.

Discussion
----------

[Bug] Fix RateLimiter framework configuration

| Q             | A
| ------------- | ---
| Branch?       | 5.x for features <!-- see below -->
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       |  - <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT
| Doc PR        | -

Small mistake in the rate limiter configuration, instead of unsetting the `storage_service` option the never existing `storage` option was unset, resulting into an application error when trying to use a Limiter in your application.

The exception was:
```
Uncaught PHP Exception: The option "storage_service" does not exist. Defined options are: "id", "interval", "limit", "rate", "strategy"."
```

This was introduced in #38204, so a highlight for @wouterj to check this :)

Commits
-------

b360320890 [Bug] Fix RateLimiter framework configuration
2020-10-11 07:57:58 +02:00