Skip to content

[Uid commands] Cleanups after review #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 23, 2021

Conversation

nicolas-grekas
Copy link

Review of symfony#39883

@nicolas-grekas nicolas-grekas force-pushed the uid-commands branch 5 times, most recently from 7b7eaba to aadac71 Compare February 23, 2021 17:05
@fancyweb fancyweb merged commit cd9d646 into fancyweb:uid-commands Feb 23, 2021
@nicolas-grekas nicolas-grekas deleted the uid-commands branch February 23, 2021 17:28
fancyweb pushed a commit that referenced this pull request Mar 19, 2021
This PR was merged into the 5.3-dev branch.

Discussion
----------

[Security] Added debug:firewall command

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fix symfony#39321
| License       | MIT
| Doc PR        | symfony/symfony-docs#14982
| Tags | #SymfonyHackday

### Subtasks
- [x] Add list view (for use without arguments)
- [x] Add more information to list view
- [x] Add detail view (for use with `firewall` argument)
- [x] Add more information to detail view table
- [x] Add authenticators list
- [x] Add event listeners & events (copy from `debug:event-listener`)
- [x] Add `--include-listeners` option (default: false)
- [x] Add helptext
- [x] Add documentation

### Moved outside of current scope
- Add allowed badges

### Usage (and example output) for a list
`bin/console debug:firewall`

```
Firewalls
=========

 The following firewalls are defined:
 --------
  Name
 --------
  dev
  public
  main
 --------

 // To view details of a specific firewall, re-run this command with a firewall name. (e.g. debug:firewall
 // main)
```

### Usage (and example output) for details
`bin/console debug:firewall main`

```
Firewall "main"
===============

 ----------------------- ---------------------------------------------------
  Option                  Value
 ----------------------- ---------------------------------------------------
  Name                    main
  Context                 main
  Lazy                    Yes
  Stateless               No
  User Checker            security.user_checker
  Provider                security.user.provider.concrete.app_user_provider
  Entry Point             App\Security\LoginFormAuthenticator
  Access Denied URL
  Access Denied Handler
 ----------------------- ---------------------------------------------------

User switching
--------------

 ----------- ---------------------------------------------------
  Option      Value
 ----------- ---------------------------------------------------
  Parameter   test
  Provider    security.user.provider.concrete.app_user_provider
  User Role   ROLE_SWITCH_POSSIBLE
 ----------- ---------------------------------------------------

Event listeners for firewall "main"
===================================

"Symfony\Component\Security\Http\Event\LoginSuccessEvent" event
---------------------------------------------------------------

 ------- -------------------------------------------------------------------------------------------- ----------
  Order   Callable                                                                                     Priority
 ------- -------------------------------------------------------------------------------------------- ----------
  #1      Symfony\Component\Security\Http\EventListener\UserCheckerListener::postCheckCredentials()    256
  #2      Symfony\Component\Security\Http\EventListener\SessionStrategyListener::onSuccessfulLogin()   0
  #3      Symfony\Component\Security\Http\EventListener\RememberMeListener::onSuccessfulLogin()        0
  #4      App\Security\UpdateLastLogin::__invoke()                                                     0
  symfony#5      Symfony\Component\Security\Http\EventListener\PasswordMigratingListener::onLoginSuccess()    0
 ------- -------------------------------------------------------------------------------------------- ----------

"Symfony\Component\Security\Http\Event\LogoutEvent" event
---------------------------------------------------------

 ------- ------------------------------------------------------------------------------------------- ----------
  Order   Callable                                                                                    Priority
 ------- ------------------------------------------------------------------------------------------- ----------
  #1      Symfony\Component\Security\Http\EventListener\DefaultLogoutListener::onLogout()             64
  #2      Symfony\Component\Security\Http\EventListener\SessionLogoutListener::onLogout()             0
  #3      Symfony\Component\Security\Http\EventListener\RememberMeLogoutListener::onLogout()          0
  #4      Symfony\Component\Security\Http\EventListener\CsrfTokenClearingLogoutListener::onLogout()   0
 ------- ------------------------------------------------------------------------------------------- ----------

"Symfony\Component\Security\Http\Event\CheckPassportEvent" event
----------------------------------------------------------------

 ------- ------------------------------------------------------------------------------------------ ----------
  Order   Callable                                                                                   Priority
 ------- ------------------------------------------------------------------------------------------ ----------
  #1      Symfony\Component\Security\Http\EventListener\LoginThrottlingListener::checkPassport()     2080
  #2      Symfony\Component\Security\Http\EventListener\UserProviderListener::checkPassport()        2048
  #3      Symfony\Component\Security\Http\EventListener\UserProviderListener::checkPassport()        1024
  #4      Symfony\Component\Security\Http\EventListener\CsrfProtectionListener::checkPassport()      512
  symfony#5      Symfony\Component\Security\Http\EventListener\UserCheckerListener::preCheckCredentials()   256
  symfony#6      App\Security\DisallowBannedUsers::__invoke()                                               0
  symfony#7      Symfony\Component\Security\Http\EventListener\CheckCredentialsListener::checkPassport()    0
 ------- ------------------------------------------------------------------------------------------ ----------

"Symfony\Component\Security\Http\Event\LoginFailureEvent" event
---------------------------------------------------------------

 ------- ----------------------------------------------------------------------------------- ----------
  Order   Callable                                                                            Priority
 ------- ----------------------------------------------------------------------------------- ----------
  #1      Symfony\Component\Security\Http\EventListener\RememberMeListener::onFailedLogin()   0
 ------- ----------------------------------------------------------------------------------- ----------

Authenticators for firewall "main"
==================================

 // @todo: List authenticator information

```

Commits
-------

a9dea1d [Security] Added debug:firewall command
fancyweb pushed a commit that referenced this pull request May 21, 2021
…h case insensitive (javiereguiluz)

This PR was merged into the 5.3-dev branch.

Discussion
----------

[FrameworkBundle] Make debug:event-dispatcher search case insensitive

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

I was playing with the new features of `debug:event-dispatcher` and I thought that making the new search feature case insensitive could be better:

### Before

```
$ php bin/console debug:event-dispatcher mailer

 [WARNING] The event "mailer" does not have any registered listeners.
```

### After

```
$ php bin/console debug:event-dispatcher mailer

Registered Listeners of Event Dispatcher "debug.event_dispatcher" for "Symfony\Component\Mailer\Event\MessageEvent" Event
=========================================================================================================================

 ------- --------------------------------------------------------------------------- ----------
  Order   Callable                                                                    Priority
 ------- --------------------------------------------------------------------------- ----------
  #1      Symfony\Component\Mailer\EventListener\MessageListener::onMessage()         0
  #2      Symfony\Component\Mailer\EventListener\EnvelopeListener::onMessage()        -255
  #3      Symfony\Component\Mailer\EventListener\MessageLoggerListener::onMessage()   -255
 ------- --------------------------------------------------------------------------- ----------
```

Commits
-------

1e4c7d9 [FrameworkBundle] Make debug:event-dispatcher search case insensitive
fancyweb pushed a commit that referenced this pull request May 21, 2021
…l class_exists() on null (derrabus)

This PR was merged into the 4.4 branch.

Discussion
----------

[DependencyInjection][ProxyManagerBridge] Don't call class_exists() on null

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

PHP 8.1 complains if we pass `null` to `class_exists()` or `interface_exists()`:

> class_exists(): Passing null to parameter `#1` ($class) of type string is deprecated

Commits
-------

88520e5 Don't call class_exists() on null
nicolas-grekas pushed a commit that referenced this pull request May 23, 2021
This PR was merged into the 5.2 branch.

Discussion
----------

[VarDumper] Don't pass null to parse_url()

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

This PR fixes a deprecation warning on PHP 8.1:

> parse_url(): Passing null to parameter `#1` ($url) of type string is deprecated

Commits
-------

f1de7a0 [VarDumper] Don't pass null to parse_url()
fancyweb pushed a commit that referenced this pull request Jun 14, 2021
This PR was submitted for the 5.4 branch but it was squashed and merged into the 4.4 branch instead.

Discussion
----------

[Process] Fix incorrect parameter type

In the affected line of code, fclose() should ONLY be passed a parameter of type resource, but fopen() can return a value of type bool (if the fopen() fails). This results in a fatal error under PHP 8: Fatal error: Uncaught TypeError: fclose(): Argument #1 ($stream) must be of type resource, bool given.

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

Commits
-------

d1579a2 [Process] Fix incorrect parameter type
fancyweb pushed a commit that referenced this pull request Dec 27, 2021
…sport (veewee)

This PR was merged into the 5.3 branch.

Discussion
----------

[Notifier] Use correct factory for the msteams transport

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

Creating a microsoft teams transport through the `Notifier` `Transport::fromDsn()` class results in an exception:

```
PHP Fatal error:  Uncaught TypeError: Symfony\Component\Notifier\Bridge\MicrosoftTeams\MicrosoftTeamsTransport::__construct(): Argument #1 ($path) must be of type string, null given, called in /vendor/symfony/notifier/Transport.php on line 186 and defined in /vendor/symfony/microsoft-teams-notifier/MicrosoftTeamsTransport.php:35
Stack trace:

* snap *
```

This PR uses the correct ms teams transport factory instead.
It is pointed at the `5.3` branch, in which this specific transport was introduced.
The error is also there in all versions upwards. See https://github.com/symfony/symfony/blob/6.1/src/Symfony/Component/Notifier/Transport.php#L84

Commits
-------

87edd23 [Notifier] Use correct factory for the msteams transport
fancyweb pushed a commit that referenced this pull request Jan 20, 2022
… AssetsInstallCommand (pavol-tk, GromNaN)

This PR was squashed before being merged into the 4.4 branch.

Discussion
----------

[FrameworkBundle] Avoid calling rtrim(null, '/') in AssetsInstallCommand

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

Avoid following deprecation notice:
```
php.INFO: Deprecated: rtrim(): Passing null to parameter #1 ($string) of type string is deprecated
```

Commits
-------

3d92f98 [FrameworkBundle] Avoid calling rtrim(null, '/') in AssetsInstallCommand
fancyweb added a commit that referenced this pull request Jan 20, 2022
… on denormalization (JustDylan23)

This PR was squashed before being merged into the 6.0 branch.

Discussion
----------

[Serializer] Fix AbstractObjectNormalizer TypeError on denormalization

| Q             | A
| ------------- | ---
| Branch?       | 6.0
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix symfony#44872
| License       | MIT
| Doc PR        |

When using dependency injection to get the serializer (instead of manually instantiating it) the object normalizer that is injected into that serializer throws a value exception when doing denormalizing the following:

```php
class ObjectOuter {
  public ObjectInner $inner;
}

class ObjectInner {
  public $foo;
}

public function testDenormalizeRecursiveWithObjectAttributeWithStringValue()
{
    $extractor = new ReflectionExtractor();
    $normalizer = new ObjectNormalizer(null, null, null, $extractor);
    $serializer = new Serializer([$normalizer]);

    $obj = $serializer->denormalize(['inner' => 'foo'], ObjectOuter::class);
    $this->assertInstanceOf(ObjectInner::class, $obj->getInner());
    }
```

This throws
```php
TypeError:
Symfony\Component\Serializer\Normalizer\AbstractNormalizer::prepareForDenormalization(): Argument #1 ($data) must be of type object|array|null, string given, called in /var/www/symfony/vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php on line 368

  at vendor/symfony/serializer/Normalizer/AbstractNormalizer.php:299
  at Symfony\Component\Serializer\Normalizer\AbstractNormalizer->prepareForDenormalization('test string')
     (vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:368)
  at Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer->denormalize('test string', 'App\\Entity\\User', null, array('cache_key' => 'c93a6d4efa206ea58a62cc6b7fab8dfb', 'deserialization_path' => 'author'))
     (vendor/symfony/serializer/Serializer.php:238)
  at Symfony\Component\Serializer\Serializer->denormalize('test string', 'App\\Entity\\User', null, array('cache_key' => 'c93a6d4efa206ea58a62cc6b7fab8dfb', 'deserialization_path' => 'author'))
     (vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:559)
  at Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer->validateAndDenormalize(array(object(Type)), 'App\\Entity\\Blog', 'author', 'test string', null, array('cache_key' => '44db5a926a1544b1a8585af40107ca3a', 'deserialization_path' => 'author'))
     (vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:401)
  at Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer->denormalize(array('author' => 'test string'), 'App\\Entity\\Blog', null, array('cache_key' => '44db5a926a1544b1a8585af40107ca3a'))
     (vendor/symfony/serializer/Serializer.php:238)
  at Symfony\Component\Serializer\Serializer->denormalize(array('author' => 'test string'), 'App\\Entity\\Blog')
     (src/Controller/BugReproductionController.php:18)
  at App\Controller\BugReproductionController->test(object(Serializer))
     (vendor/symfony/http-kernel/HttpKernel.php:152)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:74)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:202)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35)
  at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run()
     (vendor/autoload_runtime.php:29)
  at require_once('/var/www/symfony/vendor/autoload_runtime.php')
     (public/index.php:5)
```

Refer to: symfony#44881 for the description.
Was in the middle of changing the base branch and accidentally pushed when the branch was deleted.

`@fancyweb` I implemented the requested changes

Commits
-------

89092ea [Serializer] Fix AbstractObjectNormalizer TypeError on denormalization
fancyweb pushed a commit that referenced this pull request Jan 24, 2022
…s (xesxen)

This PR was merged into the 5.4 branch.

Discussion
----------

[RateLimiter] Resolve crash on near-round timestamps

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

Occasionally timestamps will be fully round (eg. 1234567890.000000) or close to it (eg. 1234567890.000031).

When converting those specific float timestamps to string in SlidingWindow (due to `DateTimeImmutable::createFromFormat`), the number is formatted by PHP without any digits. This causes the resulting value of SlidingWindow::getRetryAfter() to be violated with the boolean value `false`.

This patch formats the float to include the decimal digits.

```
Return value of Symfony\Component\RateLimiter\Policy\SlidingWindow::getRetryAfter() must be an instance of DateTimeImmutable, bool returned
#0 .../vendor/symfony/rate-limiter/Policy/SlidingWindowLimiter.php(84): Symfony\Component\RateLimiter\Policy\SlidingWindow->getRetryAfter()
#1 .../usercode.php(123): Symfony\Component\RateLimiter\Policy\SlidingWindowLimiter->consume(1)
```

Commits
-------

4965952 [RateLimiter] Resolve crash on near-round timestamps
fancyweb pushed a commit that referenced this pull request Jan 28, 2022
… resource (Seldaek)

This PR was squashed before being merged into the 4.4 branch.

Discussion
----------

[Process] Avoid calling fclose on an already closed resource

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

I got this in Composer while interrupting an install process with Ctrl-C.

```
PHP Fatal error:  Uncaught TypeError: fclose(): supplied resource is not a valid stream resource in /var/www/composer/vendor/symfony/process/Pipes/AbstractPipes.php:50
Stack trace:
#0 /var/www/composer/vendor/symfony/process/Pipes/AbstractPipes.php(50): fclose()
#1 /var/www/composer/vendor/symfony/process/Pipes/UnixPipes.php(50): Symfony\Component\Process\Pipes\AbstractPipes->close()
#2 [internal function]: Symfony\Component\Process\Pipes\UnixPipes->__destruct()
#3 {main}
  thrown in /var/www/composer/vendor/symfony/process/Pipes/AbstractPipes.php on line 50
```

I am assuming it's due to a process which was not closed properly, which is very likely given we run a bunch of them concurrently.. It's pretty hard to debug as it's also hard to reproduce, so I am not sure what to do except handle this case gracefully in the close/__destruct function and hope that at least lets it clean up processes without crashing this way.

Commits
-------

a9e43a7 [Process] Avoid calling fclose on an already closed resource
fancyweb pushed a commit that referenced this pull request Feb 9, 2022
…alebedev80)

This PR was merged into the 4.4 branch.

Discussion
----------

[Cache] Fix connecting to Redis via a socket file

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

In the [commit](symfony@99b4885) was done follow changes in Traits/RedisTrait.php(188)

Old code:

```$port = $hosts[0]['port'] ?? null;```

New code:

```$port = $hosts[0]['port'] ?? 6379;```

With DSN "redis:///var/run/redis/redis.sock" raise an error:

```
Redis connection "redis:///var/run/redis/redis.sock?dbindex=5" failed: php_network_getaddresses: getaddrinfo failed: Name or service not known
```

Because phpredis doesn't allow socket connections with a port

```
(new Redis)->connect('/var/run/redis/redis.sock', 6379);
```

**Error**

```
PHP Warning:  Redis::connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /root/test_redis.php on line 5
PHP Fatal error:  Uncaught RedisException: php_network_getaddresses: getaddrinfo failed: Name or service not known in /root/test_redis.php:5
Stack trace:
#0 /root/test_redis.php(5): Redis->connect()
#1 {main}
  thrown in /root/test_redis.php on line 5
```

I added additional validation of connection type (by host or socket). Also I fixed condition when RedisSentinel connection call as it supports connections by host only.

Commits
-------

214fdd1 [Cache] Fix connecting to Redis via a socket file
fancyweb pushed a commit that referenced this pull request Mar 8, 2022
…se::isNotModified` (HypeMC)

This PR was merged into the 4.4 branch.

Discussion
----------

[HttpFoundation] Fix PHP 8.1 deprecation in `Response::isNotModified`

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

If an `If-None-Match` header is provided in the request and there's no `ETag` header in the response, the following deprecation notice occurs on PHP 8.1 in `Response::isNotModified`:

```
Deprecated: strncmp(): Passing null to parameter #1 ($string1) of type string is deprecated
```

Commits
-------

b909acf [HttpFoundation] Fix PHP 8.1 deprecation in isNotModified
fancyweb pushed a commit that referenced this pull request Oct 5, 2022
…tpCache (mpdude)

This PR was merged into the 4.4 branch.

Discussion
----------

[HttpKernel] Fix a PHP 8.1 deprecation notice in HttpCache

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

PHP 8.1 may trigger a deprecation notice `PHP Deprecated:  abs(): Passing null to parameter #1 ($num) of type int|float is deprecated in .../symfony/http-kernel/HttpCache/HttpCache.php on line 721`

The reason is that `$entry->getTtl()` may return `null` for cache entries where no freshness information is present.

I think we would err on the safe side by not using stale-while-revalidate behaviour in this case.

Commits
-------

d0955c2 [HttpKernel] Fix a PHP 8.1 deprecation notice in HttpCache
fancyweb pushed a commit that referenced this pull request Oct 5, 2022
…in `NativeSessionStorage::save()` (chalasr)

This PR was merged into the 4.4 branch.

Discussion
----------

[HttpFoundation] Fix TypeError on null `$_SESSION`  in `NativeSessionStorage::save()`

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

When sending concurrent requests via ajax async to a route pointing to a controller requiring an authenticated user through a stateful - session-based - firewall that calls `SessionInterface::save()`, it happens that `$_SESSION` is `null` under some conditions which causes the following error on PHP 8.1:

> Exception 'TypeError' with message 'array_keys(): Argument #1 ($array) must be of type array, null given' in /app/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php:246
…app/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php (246)
…age::save called at /app/vendor/symfony/http-foundation/Session/Session.php (198)

The issue prevents me from upgrading to PHP 8.1 in a project I'm working on with `@jwage`.

Commits
-------

05f3e77 [HttpFoundation] Fix TypeError on null `$_SESSION`  in `NativeSessionStorage::save()`
fancyweb pushed a commit that referenced this pull request Nov 7, 2022
…ncoding body for c… (Phillip Look)

This PR was merged into the 6.1 branch.

Discussion
----------

[HttpClient][WebProfilerBundle] Catch errors when encoding body for c…

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

In Symfony 6.1 a [button to copy a request as a cURL command](symfony#43931) was introduced for the profiler.

But if I post a binary file containing null characters using the curl-http-client the `HttpClientDataCollector` throws an error.
```
Warning: Uncaught ValueError: escapeshellarg(): Argument #1 ($arg) must not contain any null bytes
```

My solution is to catch the `ValueError` in this situation and to return `null` as the resulting curl command. Returning `null` seems to be the standard handling for unexpectad values in this data collector.

Commits
-------

36e6fa0 [HttpClient][WebProfilerBundle] Catch errors when encoding body for curl command line
fancyweb pushed a commit that referenced this pull request Nov 7, 2022
…ver with null on non-nullable argument (GromNaN)

This PR was merged into the 6.1 branch.

Discussion
----------

[HttpKernel] Fix deprecation for DateTimeValueResolver with null on non-nullable argument

| Q             | A
| ------------- | ---
| Branch?       | 6.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | https://github.com/symfony/symfony/pull/48098/files#r1013918566
| License       | MIT
| Doc PR        | n/a

Remove deprecation message when the value is `null` and the controller argument is not nullable.

```
Deprecated: DateTimeImmutable::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated
```

This class have been modified in 6.2. The new test case needs to be updated.

Commits
-------

1d7387b Fix deprecation notice when date argument is not nullable and null value is provided
fancyweb pushed a commit that referenced this pull request Dec 9, 2022
…iously defined date attribute to the expected class (GromNaN)

This PR was merged into the 6.1 branch.

Discussion
----------

[HttpKernel] In DateTimeValueResolver, convert previously defined date attribute to the expected class

| Q             | A
| ------------- | ---
| Branch?       | 6.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix https://github.com/symfony/symfony/pull/48098/files#r1013997729
| License       | MIT

Convert an instance of `DateTimeInterface` to the expected class if the value was predefined in the request attributes.

```php
# in a request listener
$request->attributes->set('date', new \DateTimeImmutable());
```

```php
class MyController
{
    public function index(\DateTime $date)
    {
        // Use the $date
    }
}
```

```
Uncaught TypeError: MyController::index(): Argument #1 ($date) must be of type DateTime, DateTimeImmutable given
```

Commits
-------

22a1567 Convert previously defined date attribute to the expected class
fancyweb pushed a commit that referenced this pull request Dec 21, 2022
…(HypeMC)

This PR was merged into the 6.2 branch.

Discussion
----------

[HttpKernel] Fix `CacheAttributeListener` priority

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

Currently the `CacheAttributeListener` & the `IsGrantedAttributeListener` have the same priority:

```
Registered Listeners for "kernel.controller_arguments" Event
============================================================

 ------- --------------------------------------------------------------------------------------------------------- ----------
  Order   Callable                                                                                                  Priority
 ------- --------------------------------------------------------------------------------------------------------- ----------
  #1      Symfony\Component\HttpKernel\EventListener\CacheAttributeListener::onKernelControllerArguments()          10
  #2      Symfony\Component\Security\Http\EventListener\IsGrantedAttributeListener::onKernelControllerArguments()   10
  #3      Symfony\Component\HttpKernel\EventListener\ErrorListener::onControllerArguments()                         0
 ------- --------------------------------------------------------------------------------------------------------- ----------
```

Since the `CacheAttributeListener` is alphabetically first, it's first to get triggered. This can cause an unauthenticated user to receive a 304 Not modified instead of a 302 Redirect, resulting in the user seeing some stale content from when they were authenticated instead of getting redirected to the login page.

This PR changes the priority of the `CacheAttributeListener` to be lower than that of the `IsGrantedAttributeListener`.

Commits
-------

90eb89f [HttpKernel] Fix CacheAttributeListener priority
fancyweb pushed a commit that referenced this pull request Feb 27, 2023
…ixed attributes (delbertooo)

This PR was submitted for the 6.2 branch but it was merged into the 5.4 branch instead.

Discussion
----------

[FrameworkBundle] Fix denyAccessUnlessGranted for mixed attributes

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

Checking authorization against anything that isn't `array|string` will cause PHP errors now. The method `AbstractController::denyAccessUnlessGranted()` sets the given *single* attribute into the exception in case of denied access. The `AuthorizationCheckerInterface` defines that the attribute can be anything, even objects. The parameter type hint `array|string` of `AccessDeniedException::setAttributes()` want's an array of attributes (or a string for convenience).

# Example

```php
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class MyCustomAttribute
{
}

class ProfileController extends AbstractController
{
    public function index(): Response
    {
        $this->denyAccessUnlessGranted(new MyCustomAttribute()); // 💥 ERROR: Symfony\Component\Security\Core\Exception\AccessDeniedException::setAttributes(): Argument #1 ($attributes) must be of type array|string, [...]

        $user = $this->getUser();

        return new Response('Well hi there '.$user->getFirstName());
    }
}
```

# The fix

As the given attribute is a *single* attribute: always wrap it into an array when creating the exception, because the exception expects an array of attributes.

Commits
-------

9ed77f3 [FrameworkBundle] Fix denyAccessUnlessGranted for mixed attributes
fancyweb pushed a commit that referenced this pull request May 16, 2023
…ring, bool given (danepowell)

This PR was merged into the 5.4 branch.

Discussion
----------

[Console] trim(): Argument #1 () must be of type string, bool given

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

Additionally (see https://symfony.com/releases):
 - Always add tests and ensure they pass.
 - 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 the latest branch.
 - For new features, provide some code snippets to help understand usage.
 - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry
 - Never break backward compatibility (see https://symfony.com/bc).
-->

If you run a Symfony Console application in Git Bash, ANSICON is not set out of the box and results in this (suppressed) error:
> trim(): Argument ($string) must be of type string, bool given

AFAICT, this method is only called from Application::run() and errors are suppressed. So users will never actually see that error. Still, it could have side effects and breaks downstream projects: box-project/box#990

Commits
-------

324b160 trim(): Argument #1 () must be of type string, bool given
fancyweb pushed a commit that referenced this pull request May 16, 2023
* 5.4:
  trim(): Argument #1 () must be of type string, bool given
  [Dumper] Trim leading newlines when checking if value begins with a space
  Fix the list of supported shells for completions in a phar
fancyweb pushed a commit that referenced this pull request May 16, 2023
* 6.2:
  Fix test class name
  trim(): Argument #1 () must be of type string, bool given
  Check if trace.curlCommand is defined in profiler
  [Dumper] Trim leading newlines when checking if value begins with a space
  [FrameworkBundle] Make service edges unique
  Fix the list of supported shells for completions in a phar
  Fix the usage of the zsh completion through the fpath discovery
fancyweb pushed a commit that referenced this pull request Jul 31, 2023
…he monorepo (fabpot, dunglas, KorvinSzanto, xabbuh, aimeos, ahundiak, Danielss89, rougin, csunolgomez, Jérôme Parmentier, mtibben, Nyholm, ajgarlag, uphlewis, samnela, grachevko, nicolas-grekas, tinyroy, danizord, Daniel Degasperi, rbaarsma, Ekman, 4rthem, derrabus, mleczakm, iluuu1994, Tobion, chalasr, lemon-juice, franmomu, cidosx, erikn69, AurelienPillevesse)

This PR was merged into the 6.4 branch.

Discussion
----------

[PsrHttpMessageBridge] Import the bridge into the monorepo

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

⚠️ Don't squash!

I propose to import the `symfony/psr-http-message-bridge` package into the Symfony monorepo for further maintenance.

Commits
-------

e40dd66 [PsrHttpMessageBridge] Patch return types and fix CS
266c09f [PsrHttpMessageBridge] Import the bridge into the monorepo
0c0323a Add 'src/Symfony/Bridge/PsrHttpMessage/' from commit '581ca6067eb62640de5ff08ee1ba6850a0ee472e'
581ca60 Prepare release 2.3.1
45d0349 Fix CS
6410dda bug symfony#122 Don't rely on Request::getPayload() to populate the parsed body (nicolas-grekas)
ef03b6d Don't rely on Request::getPayload() to populate the parsed body
3c62b81 minor symfony#120 Prepare release 2.3.0 (derrabus)
96acbfd Prepare release 2.3.0
7eedd34 feature symfony#119 Implement ValueResolverInterface (derrabus)
0b54b85 Implement ValueResolverInterface
6b2f5df feature symfony#117 Leverage `Request::getPayload()` to populate the parsed body of PSR-7 requests (AurelienPillevesse)
3a8caad Leverage `Request::getPayload()` to populate the parsed body of PSR-7 requests
18c9e82 minor symfony#118 Add native types where possible (derrabus)
4fd4323 Add native types where possible
28a732c minor symfony#115 Prepare the 2.2.0 release (derrabus)
7944831 cs fix
99ddcaa Prepare the 2.2.0 release
8a5748d feature symfony#113 Bump psr/http-message version (erikn69)
ec83c1c Bump psr/http-message version
694016e feature symfony#114 Drop support for Symfony 4 (derrabus)
b360b35 Drop support for Symfony 4
998d8d2 minor symfony#111 Adjustments for PHP CS Fixer 3 (derrabus)
5fa5f62 Adjustments for PHP CS Fixer 3
a125b93 minor symfony#110 Add PHP 8.2 to CI (derrabus)
4592df2 Add PHP 8.2 to CI
4617ac3 bug symfony#109 perf: ensure timely flush stream buffers (cidosx)
8c8a75b perf: ensure timely flush stream buffers
d444f85 Update changelog
155a7ae bug symfony#107 Ignore invalid HTTP headers when creating PSR7 objects (nicolas-grekas)
9a78a16 Ignore invalid HTTP headers when creating PSR7 objects
bdb2871 minor symfony#104 Add missing .gitattributes (franmomu)
808561a Add missing .gitattributes
316f5cb bug symfony#103 Fix for wrong type passed to moveTo() (lemon-juice)
7f3b5c1 Fix for wrong type passed to moveTo()
22b37c8 minor symfony#101 Release v2.1.2 (chalasr)
c382d76 Release v2.1.2
c81476c feature symfony#100 Allow Symfony 6 (chalasr)
c7a0be3 Allow Symfony 6
df83a38 minor symfony#98 Add PHP 8.1 to CI (derrabus)
b2bd334 Add PHP 8.1 to CI
824711c minor symfony#99 Add return types to fixtures (derrabus)
f8f70fa Add return types to fixtures
d558dcd minor symfony#97 Inline $tmpDir (derrabus)
d152649 Inline $tmpDir
f12a9e6 minor symfony#96 Run PHPUnit on GitHub Actions (derrabus)
ab64c69 Run PHPUnit on GitHub Actions
c901299 bug symfony#95 Allow `psr/log` 2 and 3 (derrabus)
8e13ae4 Allow psr/log 2 and 3
26068fa Minor cleanups
87fabb9 Fix copyright year
3d9241f minor symfony#92 remove link to sensio extra bundle which removed psr7 support (Tobion)
7078739 remove link to sensio extra bundle which removed psr7 support
81db2d4 feature symfony#89 PSR HTTP message converters for controllers (derrabus)
aa26e61 PSR HTTP message converters for controllers
e62b239 minor symfony#91 Fix CS (derrabus)
2bead22 Fix CS
488df9b minor symfony#90 Fix CI failures with Xdebug 3 and test on PHP 7.4/8.0 as well (derrabus)
a6697fd Fix CI failures with Xdebug 3 and test on PHP 7.4/8.0 as well
c62f7d0 Update branch-alias
51a21cb Update changelog
a20fff9 bug symfony#87 Fix populating server params from URI in HttpFoundationFactory (nicolas-grekas)
4933e04 bug symfony#86 Create cookies as raw in HttpFoundationFactory (nicolas-grekas)
66095a5 Fix populating server params from URI in HttpFoundationFactory
42cca49 Create cookies as raw in HttpFoundationFactory
cffb3a8 bug symfony#85 Fix BinaryFileResponse with range to psr response conversion (iluuu1994)
5d5932d Fix BinaryFileResponse with range to psr response conversion
e44f249 bug symfony#81 Don't normalize query string in PsrHttpFactory (nicolas-grekas)
bc25829 Don't normalize query string in PsrHttpFactory
df735ec bug symfony#78 Fix populating default port and headers in HttpFoundationFactory (mleczakm)
4f30401 Fix populating default port and headers in HttpFoundationFactory
1309b64 bug symfony#77 fix conversion for https requests (4rthem)
e86de3f minor symfony#79 Allow installation on php 8 (derrabus)
9243f93 Allow installation on php 8.
d336c73 fix conversion for https requests
126903c Fix format of CHANGELOG.md
ce709cd feature symfony#75 Remove deprecated code (fabpot)
dfc5238 Remove deprecated code
9d3e80d bug symfony#72 Use adapter for UploadedFile objects (nicolas-grekas)
a4f9f6d Use adapter for UploadedFile objects
ec7892b Fix CHANGELOG, bump branch-alias
7ab4fe4 minor symfony#70 Updated CHANGELOG (rbaarsma)
9ad4bcc Updated CHANGELOG
c4c904a minor symfony#71 Cleanup after bump to Symfony v4.4 (nicolas-grekas)
e9a9557 Cleanup after bump to Symfony v4.4
3d10a6c feature symfony#66 Add support for streamed Symfony request (Ekman)
df26630 Add support for streamed Symfony request
5aa8ca9 bug symfony#69 Allow Symfony 5.0 (rbaarsma)
1158149 Allow Symfony 5.0
81ae86d Merge branch '1.1'
a33352a bug symfony#64 Fixed createResponse (ddegasperi)
7a4b449 minor symfony#65 Fix tests (ajgarlag)
19905b0 Fix tests
580de38 Fixed createResponse
9ab9d71 minor symfony#63 Added links to documentation (Nyholm)
59b9406 Added links to documentation
c1cb51c feature symfony#50 Add support for streamed response (danizord)
4133c7a bug symfony#48 Convert Request/Response multiple times (Nyholm)
8564bf7 Convert Request/Response multiple times
7cc1605 Add support for streamed response
aebc14b feature symfony#62 bump to PHP 7.1 (nicolas-grekas)
8e10923 bump to PHP 7.1
5e5e0c3 Revert "Undeprecate DiactorosFactory for 1.1"
921f866 Undeprecate DiactorosFactory for 1.1
8592ca3 bug symfony#61 removed 'Set-Cookie' from header when it is already converted to a Symfony header cookie (tinyroy)
dd1111e removed 'Set-Cookie' from header when it is already converted to a Symfony header cookie
ba672d8 bump branch-alias
5f9a032 typo
f2c48c5 fix tests
3a52e44 bug symfony#59 Fix SameSite attribute conversion from PSR7 to HttpFoundation (ajgarlag)
5ee1f8f Fix SameSite attribute conversion from PSR7 to HttpFoundation
f6d7d3a bug symfony#58 [Bugfix] Typo header set-sookie (grachevko)
16eb6e1 minor symfony#57 Excluded tests from classmap (samnela)
36a8065 Deprecate DiactorosFactory, use nyholm/psr7 for tests
5076934 bug symfony#54 Fix symfony#51 (compatability issue with zendframework/zend-diactoros ^2.0) (uphlewis)
757ea81 [Bugfix] Typo header set-sookie
25f9c3a Excluded tests from classmap
8ff61e5 Fix compatability issue with "zendframework/zend-diactoros": "^2.0." (symfony#51)
53c15a6 updated CHANGELOG
c821241 bumped version to 1.1
f26d01f minor symfony#47 Updated changelog (Nyholm)
c2282e3 Updated changelog
eddd6c8 feature symfony#43 Create PSR-7 messages using PSR-17 factories (ajgarlag)
dd81b4b Create PSR-7 messages using PSR-17 factories
f11f173 feature symfony#45 Fixed broken build (Nyholm)
8780dd3 Fixed broken build
c2b7579 bug symfony#30 Fix the request target in PSR7 Request (mtibben)
94fcfa5 Fix the request target in PSR7 Request
64640ee minor symfony#38 Run PHP 5.3 tests on Precise (Lctrs)
64c0cb0 Run PHP 5.3 tests on Precise
b209840 minor symfony#32 Allow Symfony 4 (dunglas)
97635f1 Allow Symfony 4
147a238 minor symfony#31 test suite compatibility with PHPUnit 6 (xabbuh)
f5c46f0 test suite compatibility with PHPUnit 6
66085f2 preparing 1.0 release
533d3e4 added a CHANGELOG for 1.0
14269f9 bug symfony#28 Fix REQUEST_METHOD on symfony request (csunol)
98ab85a Fix REQUEST_METHOD on symfony request
29be4f8 updated LICENCE year
d2db47c removed obsolete CHANGELOG file
1c30b17 bug symfony#22 Fixes symfony#16 Symfony Request created without any URI (rougin)
a59c572 Fixes symfony#16 Symfony Request created without any URI
7a5aa92 bug symfony#23 Fixes symfony#9 Bridge error when no file is selected (ahundiak, Danielss89)
a1a631a Update assert error message
e5d62e6 Fixes based on code-review
101b608 Handles null file in createrequest bridge.
d16c63c bug symfony#18 Allow multiple calls to Request::getContent() (aimeos)
9624b8b Allow multiple calls to Request::getContent()
9c747c4 Merge pull request symfony#19 from xabbuh/travis-config
a388c43 update Travis CI configuration
ac5cd86 minor symfony#14 Remove use of deprecated 'deep' parameter in tests (KorvinSzanto)
305c0fe Remove use of deprecated 'deep' parameter
3664dc0 minor symfony#7 Test Diactoros Factory with PHP 5.4 (dunglas)
bab1530 Test Diactoros Factory with PHP 5.4
d7660b8 Suggest psr/http-message-implementation
dc7e308 removed the branch alias for now as we are pre 1.0
3f8977e feature #1 Initial support (dunglas)
ca41146 Initial support
01b110b added the initial set of files
fancyweb pushed a commit that referenced this pull request Mar 11, 2024
This PR was merged into the 5.4 branch.

Discussion
----------

[Process] Fixed inconsistent test

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | N/A
| License       | MIT

Sometimes the process no longer appears to be running when the signal is sent which causes a LogicException to be thrown. This doesn't appear to be consistent and I can reproduce it randomly on my local machine. To avoid having tests fail at random I decided that it's better to send the signal only if the process is still marked as running.

```bash
amne@wnbpowerbox:~/work/projects/symfony$ php7.4 src/Symfony/Component/Process/Tests/ErrorProcessInitiator.php
The process "'php' '-r' 'echo '\''ready'\''; trigger_error('\''error'\'', E_USER_ERROR);'" exceeded the timeout of 0.5 seconds.
amne@wnbpowerbox:~/work/projects/symfony$ php7.4 src/Symfony/Component/Process/Tests/ErrorProcessInitiator.php
The process "'php' '-r' 'echo '\''ready'\''; trigger_error('\''error'\'', E_USER_ERROR);'" exceeded the timeout of 0.5 seconds.
amne@wnbpowerbox:~/work/projects/symfony$ php7.4 src/Symfony/Component/Process/Tests/ErrorProcessInitiator.php
The process "'php' '-r' 'echo '\''ready'\''; trigger_error('\''error'\'', E_USER_ERROR);'" exceeded the timeout of 0.5 seconds.
amne@wnbpowerbox:~/work/projects/symfony$ php7.4 src/Symfony/Component/Process/Tests/ErrorProcessInitiator.php
The process "'php' '-r' 'echo '\''ready'\''; trigger_error('\''error'\'', E_USER_ERROR);'" exceeded the timeout of 0.5 seconds.
amne@wnbpowerbox:~/work/projects/symfony$ php7.4 src/Symfony/Component/Process/Tests/ErrorProcessInitiator.php
PHP Fatal error:  Uncaught Symfony\Component\Process\Exception\LogicException: Cannot send signal on a non running process. in /home/amne/work/projects/symfony/src/Symfony/Component/Process/Process.php:1502
Stack trace:
#0 /home/amne/work/projects/symfony/src/Symfony/Component/Process/Process.php(516): Symfony\Component\Process\Process->doSignal()
#1 /home/amne/work/projects/symfony/src/Symfony/Component/Process/Tests/ErrorProcessInitiator.php(28): Symfony\Component\Process\Process->signal()
#2 {main}
  thrown in /home/amne/work/projects/symfony/src/Symfony/Component/Process/Process.php on line 1502
```

Commits
-------

00ee4ca [Process] Fixed inconsistent test
fancyweb pushed a commit that referenced this pull request Mar 11, 2024
…read from socket (xdanik)

This PR was merged into the 5.4 branch.

Discussion
----------

[Mailer] Throw `TransportException` when unable to read from socket

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? |no
| Issues        | None
| License       | MIT

We are seeing error `fgets(): SSL: Connection reset by peer` multiple times a day from connection to Office 365 SMTP server (smtp.office365.com:587).
It's certainly related to some kind of timeout as we are sending emails from long running queue dispatcher and error shows up only occasionally and never with the first message. We are not seeing this issue with any other SMTP server, but we have not tested much past smtp.mandrillapp.com and local MailHog.

We have tried adjusting the `$pingThreshold` and `$restartThreshold` options, but without much success (well `$restartThreshold = 1` resolves the issue, but it also forces the transport to close connection after each message).

Stack trace:
```
#0 /var/www/vendor/symfony/mailer/Transport/Smtp/Stream/AbstractStream.php(77): fgets(Resource(stream))
#1 /var/www/vendor/symfony/mailer/Transport/Smtp/SmtpTransport.php(315): Symfony\Component\Mailer\Transport\Smtp\Stream\AbstractStream->readLine()
#2 /var/www/vendor/symfony/mailer/Transport/Smtp/SmtpTransport.php(181): Symfony\Component\Mailer\Transport\Smtp\SmtpTransport->getFullResponse()
#3 /var/www/vendor/symfony/mailer/Transport/Smtp/SmtpTransport.php(140): Symfony\Component\Mailer\Transport\Smtp\SmtpTransport->executeCommand("RSET
", Array(1))
#4 /var/www/vendor/symfony/mailer/Mailer.php(45): Symfony\Component\Mailer\Transport\Smtp\SmtpTransport->send(Object(Symfony\Component\Mime\Email), Null)
symfony#5 (our queue dispatcher): Symfony\Component\Mailer\Mailer->send(Object(Symfony\Component\Mime\Email))
```

App is running on PHP 8.0.28 on Debian Linux x64, Mailer v5.4.22.

I would gladly written some tests for this, but I don't know how to simulate calls to low-level stream functions like fgets.

Commits
-------

44d5b57 [Mailer] Throw TransportException when unable to read from socket
fancyweb pushed a commit that referenced this pull request Mar 11, 2024
…ling error with no ExpectedTypes (Jeroeny)

This PR was merged into the 6.3 branch.

Discussion
----------

[HttpKernel] Fix `RequestPayloadValueResolver` handling error with no ExpectedTypes

| Q             | A
| ------------- | ---
| Branch?       | 6.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| License       | MIT

The `NotNormalizableValueException` errors in `PartialDenormalizationException->getErrors()` have a `->getExpectedTypes()` method that returns `array|null`.  The `RequestPayloadValueResolver` assumes this is always an array.

When the returned value is `null`, an Exception is thrown with `implode(): Argument #1 ($pieces) must be of type array, string given`.

Also the exception message in case of an empty array was: `This value should be of type .`.

#SymfonyHackday

Commits
-------

0af85fe Fix RequestPayloadValueResolver handling error with no ExpectedTypes
fancyweb pushed a commit that referenced this pull request Mar 11, 2024
…hen publishing a message. (jwage)

This PR was squashed before being merged into the 6.4 branch.

Discussion
----------

[Messenger] [Amqp] Handle AMQPConnectionException when publishing a message.

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix symfony#36538 Fix symfony#48241
| License       | MIT

If you have a message handler that dispatches messages to another queue, you can encounter `AMQPConnectionException` with the message "Library error: a SSL error occurred" or "a socket error occurred"  depending on if you are using tls or not or if you are running behind a load balancer or not.

You can manually reproduce this issue by dispatching a message where the handler then dispatches another message to a different queue, then go to rabbitmq admin and close the connection manually, then dispatch another message and when the message handler goes to dispatch the other message, you will get this exception:

```
a socket error occurred
#0 /vagrant/vendor/symfony/amqp-messenger/Transport/AmqpTransport.php(60): Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpSender->send()
#1 /vagrant/vendor/symfony/messenger/Middleware/SendMessageMiddleware.php(62): Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpTransport->send()
#2 /vagrant/vendor/symfony/messenger/Middleware/FailedMessageProcessingMiddleware.php(34): Symfony\Component\Messenger\Middleware\SendMessageMiddleware->handle()
#3 /vagrant/vendor/symfony/messenger/Middleware/DispatchAfterCurrentBusMiddleware.php(61): Symfony\Component\Messenger\Middleware\FailedMessageProcessingMiddleware->handle()
#4 /vagrant/vendor/symfony/messenger/Middleware/RejectRedeliveredMessageMiddleware.php(41): Symfony\Component\Messenger\Middleware\DispatchAfterCurrentBusMiddleware->handle()
symfony#5 /vagrant/vendor/symfony/messenger/Middleware/AddBusNameStampMiddleware.php(37): Symfony\Component\Messenger\Middleware\RejectRedeliveredMessageMiddleware->handle()
symfony#6 /vagrant/vendor/symfony/messenger/Middleware/TraceableMiddleware.php(40): Symfony\Component\Messenger\Middleware\AddBusNameStampMiddleware->handle()
symfony#7 /vagrant/vendor/symfony/messenger/MessageBus.php(70): Symfony\Component\Messenger\Middleware\TraceableMiddleware->handle()
symfony#8 /vagrant/vendor/symfony/messenger/TraceableMessageBus.php(38): Symfony\Component\Messenger\MessageBus->dispatch()
symfony#9 /vagrant/src/Messenger/MessageBus.php(37): Symfony\Component\Messenger\TraceableMessageBus->dispatch()
symfony#10 /vagrant/vendor/symfony/mailer/Mailer.php(66): App\Messenger\MessageBus->dispatch()
symfony#11 /vagrant/src/Mailer/Mailer.php(83): Symfony\Component\Mailer\Mailer->send()
symfony#12 /vagrant/src/Mailer/Mailer.php(96): App\Mailer\Mailer->send()
symfony#13 /vagrant/src/MessageHandler/Trading/StrategySubscriptionMessageHandler.php(118): App\Mailer\Mailer->sendEmail()
symfony#14 /vagrant/src/MessageHandler/Trading/StrategySubscriptionMessageHandler.php(72): App\MessageHandler\Trading\StrategySubscriptionMessageHandler->handle()
symfony#15 /vagrant/vendor/symfony/messenger/Middleware/HandleMessageMiddleware.php(152): App\MessageHandler\Trading\StrategySubscriptionMessageHandler->__invoke()
symfony#16 /vagrant/vendor/symfony/messenger/Middleware/HandleMessageMiddleware.php(91): Symfony\Component\Messenger\Middleware\HandleMessageMiddleware->callHandler()
symfony#17 /vagrant/vendor/symfony/messenger/Middleware/SendMessageMiddleware.php(71): Symfony\Component\Messenger\Middleware\HandleMessageMiddleware->handle()
symfony#18 /vagrant/vendor/symfony/messenger/Middleware/FailedMessageProcessingMiddleware.php(34): Symfony\Component\Messenger\Middleware\SendMessageMiddleware->handle()
symfony#19 /vagrant/vendor/symfony/messenger/Middleware/DispatchAfterCurrentBusMiddleware.php(68): Symfony\Component\Messenger\Middleware\FailedMessageProcessingMiddleware->handle()
symfony#20 /vagrant/vendor/symfony/messenger/Middleware/RejectRedeliveredMessageMiddleware.php(41): Symfony\Component\Messenger\Middleware\DispatchAfterCurrentBusMiddleware->handle()
symfony#21 /vagrant/vendor/symfony/messenger/Middleware/AddBusNameStampMiddleware.php(37): Symfony\Component\Messenger\Middleware\RejectRedeliveredMessageMiddleware->handle()
symfony#22 /vagrant/vendor/symfony/messenger/Middleware/TraceableMiddleware.php(40): Symfony\Component\Messenger\Middleware\AddBusNameStampMiddleware->handle()
symfony#23 /vagrant/vendor/symfony/messenger/MessageBus.php(70): Symfony\Component\Messenger\Middleware\TraceableMiddleware->handle()
symfony#24 /vagrant/vendor/symfony/messenger/TraceableMessageBus.php(38): Symfony\Component\Messenger\MessageBus->dispatch()
symfony#25 /vagrant/vendor/symfony/messenger/RoutableMessageBus.php(54): Symfony\Component\Messenger\TraceableMessageBus->dispatch()
symfony#26 /vagrant/vendor/symfony/messenger/Worker.php(162): Symfony\Component\Messenger\RoutableMessageBus->dispatch()
symfony#27 /vagrant/vendor/symfony/messenger/Worker.php(109): Symfony\Component\Messenger\Worker->handleMessage()
symfony#28 /vagrant/vendor/symfony/messenger/Command/ConsumeMessagesCommand.php(238): Symfony\Component\Messenger\Worker->run()
symfony#29 /vagrant/vendor/symfony/console/Command/Command.php(326): Symfony\Component\Messenger\Command\ConsumeMessagesCommand->execute()
symfony#30 /vagrant/vendor/symfony/console/Application.php(1096): Symfony\Component\Console\Command\Command->run()
symfony#31 /vagrant/vendor/symfony/framework-bundle/Console/Application.php(126): Symfony\Component\Console\Application->doRunCommand()
symfony#32 /vagrant/vendor/symfony/console/Application.php(324): Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand()
symfony#33 /vagrant/vendor/symfony/framework-bundle/Console/Application.php(80): Symfony\Component\Console\Application->doRun()
symfony#34 /vagrant/vendor/symfony/console/Application.php(175): Symfony\Bundle\FrameworkBundle\Console\Application->doRun()
symfony#35 /vagrant/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php(49): Symfony\Component\Console\Application->run()
symfony#36 /vagrant/vendor/autoload_runtime.php(29): Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run()
symfony#37 /vagrant/bin/console(11): require_once('...')
symfony#38 {main}
```

TODO:

- [x] Add test for retry logic when publishing messages

Commits
-------

f123370 [Messenger] [Amqp] Handle AMQPConnectionException when publishing a message.
fancyweb pushed a commit that referenced this pull request Sep 11, 2024
…rsimpsons)

This PR was merged into the 5.4 branch.

Discussion
----------

[Yaml] 🐛 throw ParseException on invalid date

| Q             | A
| ------------- | ---
| Branch?       | 5.4 <!-- 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 -->
| Issues        | None <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead -->
| License       | MIT

(found in symfony-tools/docs-builder#179)

When parsing the following yaml:
```
date: 6418-75-51
```

`symfony/yaml` will throw an exception:
```
$ php main.php
PHP Fatal error:  Uncaught Exception: Failed to parse time string (6418-75-51) at position 6 (5): Unexpected character in /tmp/symfony-yaml/vendor/symfony/yaml/Inline.php:714
Stack trace:
#0 /tmp/symfony-yaml/vendor/symfony/yaml/Inline.php(714): DateTimeImmutable->__construct()
#1 /tmp/symfony-yaml/vendor/symfony/yaml/Inline.php(312): Symfony\Component\Yaml\Inline::evaluateScalar()
#2 /tmp/symfony-yaml/vendor/symfony/yaml/Inline.php(80): Symfony\Component\Yaml\Inline::parseScalar()
#3 /tmp/symfony-yaml/vendor/symfony/yaml/Parser.php(790): Symfony\Component\Yaml\Inline::parse()
#4 /tmp/symfony-yaml/vendor/symfony/yaml/Parser.php(341): Symfony\Component\Yaml\Parser->parseValue()
symfony#5 /tmp/symfony-yaml/vendor/symfony/yaml/Parser.php(86): Symfony\Component\Yaml\Parser->doParse()
symfony#6 /tmp/symfony-yaml/vendor/symfony/yaml/Yaml.php(77): Symfony\Component\Yaml\Parser->parse()
symfony#7 /tmp/symfony-yaml/main.php(8): Symfony\Component\Yaml\Yaml::parse()
symfony#8 {main}
  thrown in /tmp/symfony-yaml/vendor/symfony/yaml/Inline.php on line 714
```

This is because the "month" is invalid. Fixing the "month" will trigger about the same issue because the "day" would be invalid.

With the current change it will throw a `ParseException`.

Commits
-------

6d71a7e 🐛 throw ParseException on invalid date
fancyweb pushed a commit that referenced this pull request Sep 20, 2024
…nse from transport (ZhukV)

This PR was squashed before being merged into the 6.4 branch.

Discussion
----------

[Notifier][TurboSMS] Process partial accepted response from transport

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | None
| License       | MIT

TurboSMS can return `null` as message id, if sms not sent to recipient. Example:

```json
{
   "response_code": 802,
   "response_status": "SUCCESS_MESSAGE_PARTIAL_ACCEPTED",
   "response_result": [
      {
         "phone": "recipient_1",
         "response_code": 406,
         "message_id": null,
         "response_status": "NOT_ALLOWED_RECIPIENT_COUNTRY"
      },
      {
         "phone": "recipient_2",
         "response_code": 0,
         "message_id": "f83f8868-5e46-c6cf-e4fb-615e5a293754",
         "response_status": "OK"
      }
   ]
}
```

And we receive error:

```
Symfony\Component\Notifier\Message\SentMessage::setMessageId(): Argument #1 ($id) must be of type string, null given, called in /code/vendor/symfony/turbo-sms-notifier/TurboSmsTransport.php on line 93
```

Symfony use only one phone number for sent, as result we check only first `response_result`.

Commits
-------

932dbe3 [Notifier][TurboSMS] Process partial accepted response from transport
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants