Skip to content

[Uid] Add the UidValueResolver argument value resolver #3

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

Closed
wants to merge 120 commits into from

Conversation

fancyweb
Copy link
Owner

No description provided.

jderusse and others added 17 commits December 2, 2021 18:12
…alizing requests (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[HttpClient] Don't reset timeout counter when initializing requests

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

Same as symfony#42896 but on initialize.

Commits
-------

8f3bdeb [HttpClient] Don't reset timeout counter when initializing requests
* 4.4:
  [HttpClient] Don't reset timeout counter when initializing requests
…no other way in Symfony 6 (alexander-schranz)

This PR was merged into the 6.0 branch.

Discussion
----------

Make enable_authenticator_manager true as there is no other way in Symfony 6

| Q             | A
| ------------- | ---
| Branch?       | 6.0 for features / 4.4, 5.3, 5.4 or 6.0 for bug fixes <!-- see below -->
| Bug fix?      | no
| 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 exist, explain below instead -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

Did read the new docs and I was confused about:

```
security:
    enable_authenticator_manager: true
```

as I thought thats the default now and there is no other way. And that seems to case as if you set it to false it will error in: https://github.com/symfony/symfony/blob/6ab662b0a8d5deabe03920a6dc0c7cbdc50a8d21/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php#L93-L95

So I would remove the `enable_authenticator_manager` also from the 6.0 docs and make this just the default to avod confusion here.

Commits
-------

b7a2ae6 Make enable_authenticator_manager true as there is no other way in Symfony 6
This PR was merged into the 5.3 branch.

Discussion
----------

[Uid] Add ulid keyword in composer.json

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

Commits
-------

669b75f [Uid] Add ulid keyword in composer.json
…rsion fix for 5.3 & 5.4 (Nek-)

This PR was merged into the 5.3 branch.

Discussion
----------

[DependencyInjection] PSR Container dependency version fix for 5.3 & 5.4

| Q             | A
| ------------- | ---
| Branch?       | 5.3 / 5.4
| Bug fix?      | somehow
| New feature?  | no
| Deprecations? | no
| License       | MIT
<!--
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 branch 5.x.
 - 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).
-->

This problem is already solved on Sf 6.0 branch and also on the component itself but for 5.4 and 5.3 if you install with `--prefer-lowest` for `symfony/symfony` package, it will install a wrong version of psr container.

Updated from symfony#44561 with `@fabpot` feedbacks.

`@derrabus` see the correct version here: https://github.com/symfony/symfony/blob/5.3/src/Symfony/Component/DependencyInjection/composer.json#L20

Commits
-------

b7644bd fix: lowest version of psr container supported
…rms (mostafazs)

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

Discussion
----------

[Form] Improve Persian (Farsi) Translation For Forms

This is a 4.4 targeting PR of symfony#44512

Original body:

> | Q             | A
> | ------------- | ---
> | Branch?       | 6.1
> | Bug fix?      | no
> | New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
> | License       | MIT
>
> Improve Persian (Farsi) Translation For Form Component Translation File.

Commits
-------

f5c2f53 [Form] Improve Persian (Farsi) Translation For Forms
$uidClass = $argument->getType();

$c = match ($format) {
Uid::FORMAT_CANONICAL => static fn (string $uid): AbstractUid => new $uidClass($uid), // TODO: this is wrong
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicolas-grekas Est-ce qu'on peut rajouter abstract public static function fromCanonical(string $uid): static; dans AbstractUid, je ne vois pas comment instancier les classes custom qui extend direct AbstractUid au format canonical (sans le connaître) ? Le constructeur ne faisant pas partie du contrat de AbstractUid.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Voir fce7a61

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check after the creating that __toString() === $uid?

return !$argument->isVariadic() &&
\is_string($request->attributes->get($argument->getName())) &&
null !== $argument->getType() &&
is_a($argument->getType(), AbstractUid::class, true);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_subclass_of actually I think

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • not abstract class

fancyweb and others added 11 commits December 13, 2021 17:53
…y on destruct (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[HttpClient] Fix closing curl-multi handle too early on destruct

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

For some reason, the garbage collector can decide to destruct the `CurlClientState` before the responses that reference them.
When this happens, the curl-multi handle is closed and responses end up in a broken state.
This fixes it by not closing the multi-handle on destruct/reset.

This also fixes configuring the multi-handle on reset.

Commits
-------

c0602fd [HttpClient] Fix closing curl-multi handle too early on destruct
* 4.4:
  [HttpClient] Fix closing curl-multi handle too early on destruct
  [Form] Improve Persian (Farsi) Translation For Forms
* 5.3:
  [HttpClient] Fix closing curl-multi handle too early on destruct
  [PropertyInfo] fix precedence of __get() vs properties
  [Form] Improve Persian (Farsi) Translation For Forms
  [Uid] Add ulid keyword in composer.json
  fix: lowest version of psr container supported
  [HttpClient] Don't reset timeout counter when initializing requests
* 5.4:
  [HttpClient] Fix closing curl-multi handle too early on destruct
  [PropertyInfo] fix precedence of __get() vs properties
  [Form] Improve Persian (Farsi) Translation For Forms
  [Uid] Add ulid keyword in composer.json
  fix: lowest version of psr container supported
  [HttpClient] Don't reset timeout counter when initializing requests
* 6.0:
  [HttpClient] Fix closing curl-multi handle too early on destruct
  [PropertyInfo] fix precedence of __get() vs properties
  [Form] Improve Persian (Farsi) Translation For Forms
  [Uid] Add ulid keyword in composer.json
  fix: lowest version of psr container supported
  Make enable_authenticator_manager true as there is no other way in Symfony 6
  [HttpClient] Don't reset timeout counter when initializing requests
* 6.0:
  [DI] fix merge
…illaume-a)

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

Discussion
----------

[Console] Issue 43602 : Add fish completion

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix symfony#43602
| License       | MIT

I tried to implement fish auto completion.
I hope it will work fine for you guys, let me know.

You can execute `bin/console completion fish >> ~/.config/fish/completions/sf_console.fish` and source the file

Commits
-------

157c8c0 [Console] Issue 43602 : Add fish completion
@fancyweb fancyweb force-pushed the uid/arg-resolver branch 2 times, most recently from b2c1b7f to fd22d35 Compare December 17, 2021 08:23
nicolas-grekas and others added 12 commits December 17, 2021 10:28
…:last()` method (fractalzombie)

This PR was merged into the 6.1 branch.

Discussion
----------

[Messenger] Added generic template for `Envelope::last()` method

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

Added possibility to PHPStorm generic support for Envelope::last method, no need more `/** `@var` SomeStampClass */`

Commits
-------

bbdc403 [Messenger] Added generic template for `Envelope::last()` method
…d PHPStan pseudo-types (EmilMassey)

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

Discussion
----------

[PropertyInfo] Add support for phpDocumentor and PHPStan pseudo-types

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

More and more apps are using pseudo-types like `non-empty-string`, `positive-int` which are understood by static analysis tools but are not a part of the language. This PR adds support for these types to `PhpDocExtractor` and `PhpStanExtractor`. Pseudo-type is mapped to built-in type(s) (e.g. `non-empty-string` => `string`, `positive-int` => `int`, `number` => `int|float`).

This PR adds support for all pseudo-types defined by the [phpDocumentor](https://github.com/phpDocumentor/TypeResolver/tree/f8ec4ab631de5a97769e66b13418c3b8b24e81f4/src/PseudoTypes) (some of them like `list` or `true`, `false` are already supported) and [PHPStan's](https://phpstan.org/writing-php-code/phpdoc-types) basic types.

Commits
-------

3e49b0f [PropertyInfo] Add support for phpDocumentor and PHPStan pseudo-types
This PR was merged into the 6.1 branch.

Discussion
----------

[Translation] Translatable parameters

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

✅  The TwigExtension now supports messages implementing `TranslatableInterface` (https://symfony.com/blog/new-in-symfony-5-2-translatable-objects).
✅ Thanks to symfony#41858, `TranslatableMessage` now supports recursive `TranslatableInterface` as params.

❌ But using `TranslatableInterface` as params with regular messages is not supported yet.

💡 This PR addresses this issue and makes it possible to create dedicated `TranslatableInterface` implementations like the one from symfony#41136

_Note: I would like also to add `TranslatableInterface` to the `trans(?string $id)` signature method like with the one from the [TwigExtension](https://github.com/symfony/symfony/blob/6.1/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php#L111) but I don't know how to do it without breaking BC. Any advice is welcome!_

Commits
-------

5beaee8 [Translation] Translatable parameters
…nt class (derrabus)

This PR was merged into the 6.1 branch.

Discussion
----------

[Workflow] Add return type annotations to the Event class

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

Paving the road to a fully-typed Symfony 7. 😎

Commits
-------

ccc9186 [Workflow] Add return type annotations to the Event class
…KernelTestCase::getContainer() (fancyweb)

This PR was merged into the 6.1 branch.

Discussion
----------

[FrameworkBundle] Add `@return` TestContainer to KernelTestCase::getContainer()

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

From what I understood, `test.service_container` can only be an instance of `TestContainer`. Changing the return type allows autocompletion for useful methods such as `getServiceIds()` and `getRemovedIds()` (I didn't understand why they didn't showed up in my test). That's a DX improvement, can it be applied on a lower branch?

Commits
-------

812619c [FrameworkBundle] Add `@return` TestContainer to KernelTestCase::getContainer()
…Response's $body to mock transport errors (fancyweb)

This PR was merged into the 6.1 branch.

Discussion
----------

[HttpClient] Allow yielding Exception from MockResponse's  $body to mock transport errors

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

A minor DX feature to allow simulating error chunks more easily (instead of being forced to throw from a \Generator).

Commits
-------

bbfe9d8 [HttpClient] Allow yielding Exception from MockResponse's $body to mock transport errors
@fancyweb fancyweb closed this Dec 20, 2021
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 Jun 8, 2022
Prevents:

> Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

on `getDefaultName()` returning `null`
fancyweb pushed a commit that referenced this pull request Oct 5, 2022
str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
fancyweb pushed a commit that referenced this pull request Oct 5, 2022
…(HypeMC)

This PR was merged into the 5.4 branch.

Discussion
----------

[Console] Fix deprecation when description is null

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

Fixes `str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated` when `getDefaultDescription()` returns `null`, caused by symfony#46574.

Commits
-------

7a08b52 [Console] Fix deprecation when description is null
fancyweb pushed a commit that referenced this pull request Nov 14, 2022
Co-authored-by: Jérémy Derussé <jeremy@derusse.com>
fancyweb pushed a commit that referenced this pull request Nov 14, 2022
…r (jderusse, nicolas-grekas)

This PR was merged into the 6.2 branch.

Discussion
----------

[DoctrineBridge] Add an Entity Argument Resolver

| Q             | A
| ------------- | ---
| Branch?       | 6.1
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | part of symfony#40333
| License       | MIT
| Doc PR        | todo

This PR provides an Argument Resolver for Doctrine entities.

This would replace the SensioFramework's DoctrineParamConverter (in fact most of the code is copy/pasted from here) and helps users to disable the paramConverter and fix the related issue.

usage:
```yaml
sensio_framework_extra:
    request:
        converters: false
services:
    Symfony\Bridge\Doctrine\ArgumentResolver\EntityValueResolver: ~
```

```php
#[Route('/blog/{slug}')]
public function show(Post $post)
{
}
```

or with custom options
```php
#[Route('/blog/{id}')]
public function show(
  #[MapEntity(entityManager: 'foo', expr: 'repository.findNotDeletedById(id)')]
  Post $post
)
{
}
```

Commits
-------

5a3df5e Improve EntityValueResolver (#3)
4524083 Add an Entity Argument Resolver
fancyweb pushed a commit that referenced this pull request Dec 9, 2022
…for PHPStan (ogizanagi)

This PR was merged into the 6.2 branch.

Discussion
----------

[Console] Fix `OutputInterface` options int-mask for PHPStan

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

When upgrading an application to 6.2, I encountered this issue with PHPStan:

```shell
 ------ -------------------------------------------------------------------------------------------------------
  Line   Pilot/Runner/Output/MultiplexingOutput.php
 ------ -------------------------------------------------------------------------------------------------------
  79     Default value of the parameter #3 $options (0) of method
         App\Pilot\Runner\Output\MultiplexingOutput::write() is incompatible with type 1|2|4|16|32|64|128|256.
 ------ -------------------------------------------------------------------------------------------------------
```

The `MultiplexingOutput` implements the `OutputInterface` and defined `0` as the default value for `$options`:

```php
    public function write(string|iterable $messages, bool $newline = false, int $options = 0): void
```

as defined by the interface:

https://github.com/symfony/symfony/blob/69f46f231b16be1bce1e2ecfa7f9a1fb192cda22/src/Symfony/Component/Console/Output/OutputInterface.php#L40

When trying to use `self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL` as default value:

```shell
 ------ -------------------------------------------------------------------------------------------------------
  Line   Pilot/Runner/Output/MultiplexingOutput.php
 ------ -------------------------------------------------------------------------------------------------------
  79     Default value of the parameter #3 $options (33) of method
         App\Pilot\Runner\Output\MultiplexingOutput::write() is incompatible with type 1|2|4|16|32|64|128|256.
 ------ -------------------------------------------------------------------------------------------------------
```

Or simply using `Output::write()` with specific options:

```shell
 ------ -------------------------------------------------------------------------------------------------------
  Line   Pilot/Runner/Output/MultiplexingOutput.php
 ------ -------------------------------------------------------------------------------------------------------
  81     Parameter #3 $options of method Symfony\Component\Console\Output\Output::write() expects
         1|2|4|16|32|64|128|256, 33 given.
 ------ -------------------------------------------------------------------------------------------------------
```

Using PHPStan's [`int-mask-of`](https://phpstan.org/writing-php-code/phpdoc-types#integer-masks) is the solution for this, and allows by nature the `0` value.
It was even used [at some point](symfony#47016 (comment)), but reverted to use `self::VERBOSITY_*|self::OUTPUT_*`. However, it does not behave as expected for masks.

So, either we use `int-mask-of`, or we revert to `int`?

Commits
-------

304a17a [Console] Fix OutputInterface options int-mask for PhpStan
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 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
…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
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.