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
[DI][Config] Make accessing environment variables in configuration mo… #3
Conversation
return sprintf('$this->getEnvironmentVariable(%s, %s)', $arg, $default); | ||
}, function (array $variables, $value, $default = null) { | ||
if (2 > func_num_args()) { | ||
return $variables['container']->getEnvironmentVariable($value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I am quite mistaken, this (and the same three lines down) won't work with getEnvironmentVariable
declared as protected. I would suggest keeping it public.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, fixed!
If the above is adressed, I'm fine with these changes. |
a03eb88
to
c3a4064
Compare
If you're OK @magnusnordlander , please make this patch yours. BTW, of did you feel about this way of helping (opening a PR on my fork with an alternative patch then giving back it as suggested above?) For me, it looks more efficient than commenting sometimes, should I continue with other PRs in your opinion? |
Cool. I've pushed it to my PR. Regarding the way of helping, I'm quite git savvy, so I didn't have any trouble pulling in your changes, but I might imagine that does not apply to everyone. I think what's probably easier (and what I've done previously) is to open a PR against the original PR branch. That way the contributor can merge your changes via the Github merge button. The changeset will of course get a merge commit, but from what I understand the Symfony Github toolset rebases every commit automatically anyway, so it'll still come out as a single commit in the end, once the original PR is merged. |
Cleaning the git history is also a way to help... But I'll provide a few more git commands to help with this you're right! |
…er in autowired classes (brainexe) This PR was squashed before being merged into the 3.1 branch (closes symfony#21372). Discussion ---------- [DependencyInjection] Fixed variadic method parameter in autowired classes | Q | A | ------------- | --- | Branch? | 3.1 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | -- | License | MIT Autowiring classes containing methods with variadic method parameter throws a ReflectionException in compile process: ``` PHP Fatal error: Uncaught ReflectionException: Internal error: Failed to retrieve the default value in /.../vendor/symfony/dependency-injection/Compiler/AutowirePass.php:437 Stack trace: #0 /.../vendor/symfony/dependency-injection/Compiler/AutowirePass.php(437): ReflectionParameter->getDefaultValue() #1 /.../vendor/symfony/dependency-injection/Compiler/AutowirePass.php(80): Symfony\Component\DependencyInjection\Compiler\AutowirePass::getResourceMetadataForMethod(Object(ReflectionMethod)) #2 /.../vendor/symfony/dependency-injection/Compiler/AutowirePass.php(105): Symfony\Component\DependencyInjection\Compiler\AutowirePass::createResourceForClass(Object(ReflectionClass)) #3 /.../vendor/symfony/dependency-injection/Compiler/AutowirePass.php(48): Symfony\Component\DependencyInjection\Compiler\AutowirePass->completeDefinition('__controller.Sw...', Object(Symfony\Component\DependencyInjection\Definition), Array) #4 /.../vendor/symfony/dependency-injection/Compiler/Compiler in /.../vendor/symfony/dependency-injection/Compiler/AutowirePass.php on line 437 ``` **Example:** ``` <?php class FooVariadic { public function bar(...$arguments) { } } $method = new ReflectionMethod(FooVariadic::class, 'bar'); $parameter = $method->getParameters()[0]; $parameter->getDefaultValue(); // -> ReflectionException: Internal error: Failed to retrieve the default value in ... ``` Commits ------- a7f63de [DependencyInjection] Fixed variadic method parameter in autowired classes
…s not exist (neeckeloo) This PR was merged into the 4.2-dev branch. Discussion ---------- [Messenger] Improved message when handler class does not exist | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? |no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | **Problem:** When defining a non existing messenger handler class in the `services.yml` config file, we encounter this confusing error message: ``` services: App\Handler\NonExistentHandler: tags: [messenger.message_handler] ``` ``` PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Argument 1 passed to Symfony\Component\Messenger\DependencyInjection\MessengerPass::guessHandledClasses() must be an instance of ReflectionClass, null given, called in /app/vendor/symfony/messenger/DependencyInjection/MessengerPass.php on line 93 in /app/vendor/symfony/messenger/DependencyInjection/MessengerPass.php:189 Stack trace: #0 /app/vendor/symfony/messenger/DependencyInjection/MessengerPass.php(93): Symfony\Component\Messenger\DependencyInjection\MessengerPass->guessHandledClasses(NULL, 'App\\Application...') #1 /app/vendor/symfony/messenger/DependencyInjection/MessengerPass.php(74): Symfony\Component\Messenger\DependencyInjection\MessengerPass->registerHandlers(Object(Symfony\Component\DependencyInjection\ContainerBuilder), Array) #2 /app/vendor/symfony/dependency-injection/Compiler/Compiler.php(95): Symfony\Component\Messenger\DependencyInjection\MessengerPass->process(Object(Symfony\Component\DependencyInjection\ContainerBuilder)) #3 / in /app/vendor/symfony/messenger/DependencyInjection/MessengerPass.php on line 189 ``` **Proposal:** We can throw a more relevant exception (RuntimeException) in this case to help the developer to have a better understanding of the issue. ```Invalid service "App\Handler\NonExistentHandler": class "App\Handler\NonExistentHandler" does not exist.``` Commits ------- 6ab9274 Improve error message when defining messenger handler class that does not exists
…logs (fabpot) This PR was merged into the 4.3-dev branch. Discussion ---------- [Messenger] Add missing information in messenger logs | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes-ish | New feature? | yes-ish | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | n/a | License | MIT | Doc PR | n/a When using `messenger:consume`, I get the following logs: ``` 2019-03-25T11:39:05+01:00 [info] Received message "Symfony\Component\Mailer\EnvelopedMessage" 2019-03-25T11:39:05+01:00 [warning] An exception occurred while handling message "Symfony\Component\Mailer\EnvelopedMessage" 2019-03-25T11:39:05+01:00 [info] Retrying Symfony\Component\Mailer\EnvelopedMessage - retry #1. 2019-03-25T11:39:05+01:00 [info] Sending message "Symfony\Component\Mailer\EnvelopedMessage" with "Symfony\Component\Messenger\Transport\AmqpExt\AmqpTransport" 2019-03-25T11:39:06+01:00 [info] Received message "Symfony\Component\Mailer\EnvelopedMessage" 2019-03-25T11:39:06+01:00 [warning] An exception occurred while handling message "Symfony\Component\Mailer\EnvelopedMessage" 2019-03-25T11:39:06+01:00 [info] Retrying Symfony\Component\Mailer\EnvelopedMessage - retry #2. 2019-03-25T11:39:06+01:00 [info] Sending message "Symfony\Component\Mailer\EnvelopedMessage" with "Symfony\Component\Messenger\Transport\AmqpExt\AmqpTransport" 2019-03-25T11:39:09+01:00 [info] Received message "Symfony\Component\Mailer\EnvelopedMessage" 2019-03-25T11:39:09+01:00 [warning] An exception occurred while handling message "Symfony\Component\Mailer\EnvelopedMessage" 2019-03-25T11:39:09+01:00 [info] Retrying Symfony\Component\Mailer\EnvelopedMessage - retry #3. 2019-03-25T11:39:09+01:00 [info] Sending message "Symfony\Component\Mailer\EnvelopedMessage" with "Symfony\Component\Messenger\Transport\AmqpExt\AmqpTransport" ``` So, an. error occurred, but I have no idea what's going on. The exception is in the context, but the context is not displayed by default. So, this PR fixes it. Commits ------- 20664ca [Messenger] added missing information in messenger logs
… is empty (yceruto) This PR was merged into the 4.2 branch. Discussion ---------- [HttpKernel] Fix get session when the request stack is empty | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT This bug happen behind an exception on a kernel response event, when one collector (e.g. `RequestDataCollector`) is trying to get the request session and the request stack is currently empty. **Reproducer** https://github.com/yceruto/get-session-bug (`GET /`) See logs on terminal: ```bash Apr 15 20:29:03 |ERROR| PHP 2019-04-15T20:29:03-04:00 Call to a member function isSecure() on null Apr 15 20:29:03 |ERROR| PHP PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function isSecure() on null in /home/yceruto/demos/getsession/vendor/symfony/http-kernel/EventListener/SessionListener.php:43 Apr 15 20:29:03 |DEBUG| PHP Stack trace: Apr 15 20:29:03 |DEBUG| PHP #0 /home/yceruto/demos/getsession/vendor/symfony/http-kernel/EventListener/AbstractSessionListener.php(59): Symfony\Component\HttpKernel\EventListener\SessionListener->getSession() Apr 15 20:29:03 |DEBUG| PHP #1 /home/yceruto/demos/getsession/vendor/symfony/http-foundation/Request.php(707): Symfony\Component\HttpKernel\EventListener\AbstractSessionListener->Symfony\Component\HttpKernel\EventListener\{closure}() Apr 15 20:29:03 |DEBUG| PHP #2 /home/yceruto/demos/getsession/vendor/symfony/http-kernel/DataCollector/RequestDataCollector.php(65): Symfony\Component\HttpFoundation\Request->getSession() Apr 15 20:29:03 |DEBUG| PHP #3 /home/yceruto/demos/getsession/vendor/symfony/http-kernel/Profiler/Profiler.php(167): Symfony\Component\HttpKernel\DataCollector\RequestDataCollector->collect(Object(Symfony\Component\HttpFoundation\Request), Object(Symfony\Component\HttpFoundation\Respo in /home/yceruto/demos/getsession/vendor/symfony/http-kernel/EventListener/SessionListener.php on line 43 ``` Friendly ping @nicolas-grekas as author of the previous PR symfony#28244 Commits ------- d62ca37 Fix get session when the request stack is empty
This PR was merged into the 4.3 branch. Discussion ---------- [Messenger] improve logs | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | | License | MIT | Doc PR | The logs are currently very confusing and duplicated: - When handled sync the uncaught error it logged and displayed by the console / http error handler anyway. Currently it the warning is duplicated and useless: ``` 14:26:11 WARNING [messenger] An exception occurred while handling message "{class}": OUCH, THAT HURTS! GO TO MOM! 14:26:11 ERROR [console] Error thrown while running command "{class}". Message: "OUCH, THAT HURTS! GO TO MOM!" In HandleMessageMiddleware.php line 82: [Symfony\Component\Messenger\Exception\HandlerFailedException] OUCH, THAT HURTS! GO TO MOM! ``` - When handling async is was even confusing because the actual error was logged as warning and the retry (which is a good thing) was the error. ``` 13:48:15 WARNING [messenger] An exception occurred while handling message "{class}": OUCH, THAT HURTS! GO TO MOM! 13:48:15 ERROR [messenger] Retrying {class} - retry #1. ``` Now it's must clearer and adds even context like the delay: ``` 16:20:11 ERROR [messenger] Error thrown while handling message {class}. Dispatching for retry #3 using 4000 ms delay. Error: "OUCH, THAT HURTS! GO TO MOM!" ... 16:20:15 CRITICAL [messenger] Error thrown while handling message {class}. Removing from transport after 3 retries. Error: "OUCH, THAT HURTS! GO TO MOM!" ``` Commits ------- 2ac7027 [Messenger] improve logs
…dmaicher) This PR was merged into the 4.4 branch. Discussion ---------- [FrameworkBundle] conflict with VarDumper < 4.4 | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - While trying FrameworkBundle 4.4.x-dev I noticed that I was still using VarDumper 4.3 which leads to this error: ``` > app/console cache:clear Fatal error: Uncaught Symfony\Component\ErrorHandler\Exception\ClassNotFoundException: Attempted to load class "ContextualizedDumper" from namespace "Symfony\Component\VarDumper\Dumper". Did you forget a "use" statement for another namespace? in /var/www/x/symfony/app/cache/dev/ContainerB7mbdCh/getDebug_DumpListenerService.php:13 Stack trace: #0 /var/www/x/symfony/app/cache/dev/ContainerB7mbdCh/appAppKernelDevDebugContainer.php(1357): require() #1 /var/www/x/symfony/app/cache/dev/ContainerB7mbdCh/appAppKernelDevDebugContainer.php(2282): ContainerB7mbdCh\appAppKernelDevDebugContainer->load('getDebug_DumpLi...') #2 /var/www/x/symfony/vendor/symfony/event-dispatcher/EventDispatcher.php(275): ContainerB7mbdCh\appAppKernelDevDebugContainer->ContainerB7mbdCh\{closure}() #3 /var/www/x/symfony/vendor/symfony/event-dispatcher/EventDispatcher.php(90): Symfony\Component\EventDispatcher\EventDispatcher->sortListeners('console.command') #4 /var/www/x in /var/www/x/symfony/app/cache/dev/ContainerB7mbdCh/getDebug_DumpListenerService.php on line 13 PHP Fatal error: Uncaught Symfony\Component\ErrorHandler\Exception\ClassNotFoundException: Attempted to load class "ContextualizedDumper" from namespace "Symfony\Component\VarDumper\Dumper". Did you forget a "use" statement for another namespace? in /var/www/x/symfony/app/cache/dev/ContainerB7mbdCh/getDebug_DumpListenerService.php:13 Stack trace: #0 /var/www/x/symfony/app/cache/dev/ContainerB7mbdCh/appAppKernelDevDebugContainer.php(1357): require() #1 /var/www/x/symfony/app/cache/dev/ContainerB7mbdCh/appAppKernelDevDebugContainer.php(2282): ContainerB7mbdCh\appAppKernelDevDebugContainer->load('getDebug_DumpLi...') #2 /var/www/x/symfony/vendor/symfony/event-dispatcher/EventDispatcher.php(275): ContainerB7mbdCh\appAppKernelDevDebugContainer->ContainerB7mbdCh\{closure}() #3 /var/www/x/symfony/vendor/symfony/event-dispatcher/EventDispatcher.php(90): Symfony\Component\EventDispatcher\EventDispatcher->sortListeners('console.command') #4 /var/www/x in /var/www/x/symfony/app/cache/dev/ContainerB7mbdCh/getDebug_DumpListenerService.php on line 13 Script app/console cache:clear handling the post-update-cmd event returned with error code 255 ``` So we need to use `symfony/var-dumper >= 4.4` Commits ------- 9b512c6 [FrameworkBundle] conflict with VarDumper < 4.4
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 #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 #5 Symfony\Component\Security\Http\EventListener\UserCheckerListener::preCheckCredentials() 256 #6 App\Security\DisallowBannedUsers::__invoke() 0 #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
…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
… 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
Prevents: > Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated on `getDefaultName()` returning `null`
str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
…(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
Co-authored-by: Jérémy Derussé <jeremy@derusse.com>
…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
…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
…(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
This PR was squashed before being merged into the 1.2-dev branch. Discussion ---------- Add support for streamed Symfony request As a continuation of #3 and symfony#50 . Add support for converting a `ServerRequestInterface` with a large body to a Symfony request. I'm not all too familiar with Symfony components, but I saw that a Symfony request supports `string|resource|null` as its body. Since calling `detach()` on a `StreamInterface` will make the stream unsuable I added a `$streamed` argument to the function in order to not make break any existing code, and to make it a conscious decision of the caller to stream the response. I'm happy to make any necessary changes if needed. Commits ------- df26630 Add support for streamed Symfony request
…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) #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
…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() #5 /vagrant/vendor/symfony/messenger/Middleware/AddBusNameStampMiddleware.php(37): Symfony\Component\Messenger\Middleware\RejectRedeliveredMessageMiddleware->handle() #6 /vagrant/vendor/symfony/messenger/Middleware/TraceableMiddleware.php(40): Symfony\Component\Messenger\Middleware\AddBusNameStampMiddleware->handle() #7 /vagrant/vendor/symfony/messenger/MessageBus.php(70): Symfony\Component\Messenger\Middleware\TraceableMiddleware->handle() #8 /vagrant/vendor/symfony/messenger/TraceableMessageBus.php(38): Symfony\Component\Messenger\MessageBus->dispatch() #9 /vagrant/src/Messenger/MessageBus.php(37): Symfony\Component\Messenger\TraceableMessageBus->dispatch() #10 /vagrant/vendor/symfony/mailer/Mailer.php(66): App\Messenger\MessageBus->dispatch() #11 /vagrant/src/Mailer/Mailer.php(83): Symfony\Component\Mailer\Mailer->send() #12 /vagrant/src/Mailer/Mailer.php(96): App\Mailer\Mailer->send() #13 /vagrant/src/MessageHandler/Trading/StrategySubscriptionMessageHandler.php(118): App\Mailer\Mailer->sendEmail() #14 /vagrant/src/MessageHandler/Trading/StrategySubscriptionMessageHandler.php(72): App\MessageHandler\Trading\StrategySubscriptionMessageHandler->handle() #15 /vagrant/vendor/symfony/messenger/Middleware/HandleMessageMiddleware.php(152): App\MessageHandler\Trading\StrategySubscriptionMessageHandler->__invoke() #16 /vagrant/vendor/symfony/messenger/Middleware/HandleMessageMiddleware.php(91): Symfony\Component\Messenger\Middleware\HandleMessageMiddleware->callHandler() #17 /vagrant/vendor/symfony/messenger/Middleware/SendMessageMiddleware.php(71): Symfony\Component\Messenger\Middleware\HandleMessageMiddleware->handle() #18 /vagrant/vendor/symfony/messenger/Middleware/FailedMessageProcessingMiddleware.php(34): Symfony\Component\Messenger\Middleware\SendMessageMiddleware->handle() #19 /vagrant/vendor/symfony/messenger/Middleware/DispatchAfterCurrentBusMiddleware.php(68): Symfony\Component\Messenger\Middleware\FailedMessageProcessingMiddleware->handle() #20 /vagrant/vendor/symfony/messenger/Middleware/RejectRedeliveredMessageMiddleware.php(41): Symfony\Component\Messenger\Middleware\DispatchAfterCurrentBusMiddleware->handle() #21 /vagrant/vendor/symfony/messenger/Middleware/AddBusNameStampMiddleware.php(37): Symfony\Component\Messenger\Middleware\RejectRedeliveredMessageMiddleware->handle() #22 /vagrant/vendor/symfony/messenger/Middleware/TraceableMiddleware.php(40): Symfony\Component\Messenger\Middleware\AddBusNameStampMiddleware->handle() #23 /vagrant/vendor/symfony/messenger/MessageBus.php(70): Symfony\Component\Messenger\Middleware\TraceableMiddleware->handle() #24 /vagrant/vendor/symfony/messenger/TraceableMessageBus.php(38): Symfony\Component\Messenger\MessageBus->dispatch() #25 /vagrant/vendor/symfony/messenger/RoutableMessageBus.php(54): Symfony\Component\Messenger\TraceableMessageBus->dispatch() #26 /vagrant/vendor/symfony/messenger/Worker.php(162): Symfony\Component\Messenger\RoutableMessageBus->dispatch() #27 /vagrant/vendor/symfony/messenger/Worker.php(109): Symfony\Component\Messenger\Worker->handleMessage() #28 /vagrant/vendor/symfony/messenger/Command/ConsumeMessagesCommand.php(238): Symfony\Component\Messenger\Worker->run() #29 /vagrant/vendor/symfony/console/Command/Command.php(326): Symfony\Component\Messenger\Command\ConsumeMessagesCommand->execute() #30 /vagrant/vendor/symfony/console/Application.php(1096): Symfony\Component\Console\Command\Command->run() #31 /vagrant/vendor/symfony/framework-bundle/Console/Application.php(126): Symfony\Component\Console\Application->doRunCommand() #32 /vagrant/vendor/symfony/console/Application.php(324): Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() #33 /vagrant/vendor/symfony/framework-bundle/Console/Application.php(80): Symfony\Component\Console\Application->doRun() #34 /vagrant/vendor/symfony/console/Application.php(175): Symfony\Bundle\FrameworkBundle\Console\Application->doRun() #35 /vagrant/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php(49): Symfony\Component\Console\Application->run() #36 /vagrant/vendor/autoload_runtime.php(29): Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() #37 /vagrant/bin/console(11): require_once('...') #38 {main} ``` TODO: - [x] Add test for retry logic when publishing messages Commits ------- f123370 [Messenger] [Amqp] Handle AMQPConnectionException when publishing a message.
symfony#18155