-
Notifications
You must be signed in to change notification settings - Fork 0
[DoctrineBridge] Fixed invalid unique value as composite key #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
[DoctrineBridge] Fixed invalid unique value as composite key #1
Conversation
->setParameter('{{ value }}', '"'.$expectedValue.'"') | ||
->setInvalidValue($expectedValue) | ||
->setParameter('{{ value }}', $expectedValue) | ||
->setInvalidValue($objectOne) |
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.
this seems indeed more consistent as the violation is raised at property path objectOne
anyway 👍 But see my other comment.
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.
It is my opinion too.
@@ -200,7 +200,7 @@ public function testValidateCustomErrorPath() | |||
$this->buildViolation('myMessage') | |||
->atPath('property.path.bar') | |||
->setParameter('{{ value }}', '"Foo"') | |||
->setInvalidValue('Foo') | |||
->setInvalidValue($entity2) |
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.
could this be a BC break? To not have the field value as the invalid value anymore but the entity itself?
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.
To me THIS is a bug fix, the invalid value and the value parameter should be the same.
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.
Ah true. Sorry got confused because the entities have a __toString()
method that returns the name 😊 So indeed this seems to be the cleaner solution.
} | ||
|
||
array_walk($identifiers, function (&$id, $field) use ($class) { | ||
if (!is_object($id) || method_exists($id, '__toString()') || $id instanceof \DateTimeInterface) { |
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.
method_exists($id, '__toString')
?
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.
Good catch! Fixed, thanks.
eeb5ee0
to
52f85b1
Compare
return sprintf('object("%s")', $idClass); | ||
} | ||
|
||
array_walk($identifiers, function (&$id, $field) use ($class) { |
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.
use ($class)
is not needed
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.
Thanks, refactoring leftover ^^
@@ -200,7 +200,7 @@ public function testValidateCustomErrorPath() | |||
$this->buildViolation('myMessage') | |||
->atPath('property.path.bar') | |||
->setParameter('{{ value }}', '"Foo"') | |||
->setInvalidValue('Foo') | |||
->setInvalidValue($entity2) |
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.
Ah true. Sorry got confused because the entities have a __toString()
method that returns the name 😊 So indeed this seems to be the cleaner solution.
52f85b1
to
b8f4f7f
Compare
Comments addressed, let's merge this, what do you think? |
b8f4f7f
to
e3e2e54
Compare
} | ||
|
||
array_walk($identifiers, function (&$id, $field) { | ||
if (!is_object($id) || $id instanceof \DateTimeInterface) { |
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.
I've remove the __toString
handling as I've done above before because I think it's better to have the class than the string representation in this case.
…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)) symfony#3 /.../vendor/symfony/dependency-injection/Compiler/AutowirePass.php(48): Symfony\Component\DependencyInjection\Compiler\AutowirePass->completeDefinition('__controller.Sw...', Object(Symfony\Component\DependencyInjection\Definition), Array) symfony#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
…capable of searching for the DN (lsmith77, nietonfir) This PR was merged into the 3.3-dev branch. Discussion ---------- [Security] make LdapBindAuthenticationProvider capable of searching for the DN | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#16823, symfony#20905 | License | MIT | Doc PR | symfony/symfony-docs#7420 I guess due to the separation between the user and auth provider something like the following isn't ok (note: the following works just fine for me but if course in the end the username is the DN and not the user provided shorter username): ```diff diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php index 5ebb09a..18d7825 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php @@ -70,7 +70,7 @@ class LdapBindAuthenticationProvider extends UserAuthenticationProvider */ protected function checkAuthentication(UserInterface $user, UsernamePasswordToken $token) { - $username = $token->getUsername(); + $username = $user->getUsername(); $password = $token->getCredentials(); if ('' === $password) { @@ -78,10 +78,7 @@ class LdapBindAuthenticationProvider extends UserAuthenticationProvider } try { - $username = $this->ldap->escape($username, '', LdapInterface::ESCAPE_DN); - $dn = str_replace('{username}', $username, $this->dnString); - - $this->ldap->bind($dn, $password); + $this->ldap->bind($username, $password); } catch (ConnectionException $e) { throw new BadCredentialsException('The presented password is invalid.'); } diff --git a/src/Symfony/Component/Security/Core/User/LdapUserProvider.php b/src/Symfony/Component/Security/Core/User/LdapUserProvider.php index fc42419..8194c4c 100644 --- a/src/Symfony/Component/Security/Core/User/LdapUserProvider.php +++ b/src/Symfony/Component/Security/Core/User/LdapUserProvider.php @@ -115,7 +115,7 @@ class LdapUserProvider implements UserProviderInterface { $password = $this->getPassword($entry); - return new User($username, $password, $this->defaultRoles); + return new User($entry->getDn(), $password, $this->defaultRoles); } /** ``` Therefore I created an entire new auth provider. Commits ------- 8ddd533 Merge pull request #1 from nietonfir/http_basic_ldap a783e5c Update HttpBasicLdapFactory a30191f make LdapBindAuthenticationProvider capable of searching for the DN
…utput trimming (ogizanagi) This PR was merged into the 3.3-dev branch. Discussion ---------- [FrameworkBundle] Revert AbstractDescriptorTest output trimming | Q | A | ------------- | --- | Branch? | master | Bug fix? | no, but fixes an annoying/unhelping test output and fixes false positives | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | https://github.com/symfony/symfony/pull/21129/files#diff-0e52187cbf1067a310538287da74ddb5R178 | License | MIT | Doc PR | N/A #### Before output when having a failing test, for instance, in a `TextDescriptor` fixture: ```diff There was 1 failure: 1) Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\TextDescriptorTest::testDescribeContainerDefinitionWhichIsAnAlias with data set #1 (Symfony\Component\DependencyInjection\Alias Object (...), ' // This serv...------', Symfony\Component\DependencyInjection\ContainerBuilder Object (...), array('alias_2')) Failed asserting that two strings are equal. --- Expected +++ Actual @@ @@ -' // This service is an alias for the service service_2 Information for Service "service_2" =================================== ------------------ --------------------------------- Option Value ------------------ --------------------------------- Class Full\Qualified\Class2 Tags tag1 (attr1: val1, attr2: val2) tag1 (attr3: val3) tag2 Calls setMailer Public no Synthetic yes Lazy no Shared yes Abstract no Autowired no Autowiring Types - Required File /path/to/file Factory Service factory.service Factory Method get ------------------ ---------------------------------' +' // This service is an alias for the service service_2 Information for Service "service_2" =================================== ------------------ --------------------------------- Option Value ------------------ --------------------------------- Service ID service_2 Class Full\Qualified\Class2 Tags tag1 (attr1: val1, attr2: val2) tag1 (attr3: val3) tag2 Calls setMailer Public no Synthetic yes Lazy no Shared yes Abstract no Autowired no Autowiring Types - Required File /path/to/file Factory Service factory.service Factory Method get ------------------ ---------------------------------' ``` #### After: ```diff There was 1 failure: 1) Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\TextDescriptorTest::testDescribeContainerDefinitionWhichIsAnAlias with data set #1 (Symfony\Component\DependencyInjection\Alias Object (...), ' // This serv...------', Symfony\Component\DependencyInjection\ContainerBuilder Object (...), array('alias_2')) Failed asserting that two strings are equal. --- Expected +++ Actual @@ @@ ------------------ --------------------------------- + Service ID service_2 Class Full\Qualified\Class2 Tags tag1 (attr1: val1, attr2: val2) tag1 (attr3: val3) tag2 Calls setMailer Public no Synthetic yes Lazy no Shared yes Abstract no Autowired no Autowiring Types - Required File /path/to/file Factory Service factory.service Factory Method get ------------------ ---------------------------------' ``` Commits ------- efd00ba [FrameworkBundle] Revert AbstractDescriptorTest output trimming
…e (dmaicher) This PR was merged into the 2.8 branch. Discussion ---------- [Security] fix merge of 2.7 into 2.8 + add test case | Q | A | ------------- | --- | Branch? 6D47 | 2.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#26109 | License | MIT | Doc PR | - This fixes the merge mistake done in symfony@899bf99 that caused this fail with the added test case: ``` There was 1 failure: 1) Symfony\Component\Security\Tests\Http\Firewall\UsernamePasswordFormAuthenticationListenerTest::testHandleNonStringUsername with data set #1 (false) Failed asserting that exception of type "TypeError" matches expected exception "\Symfony\Component\HttpKernel\Exception\BadRequestHttpException". Message was: "Argument 1 passed to Symfony\Component\Security\Http\ParameterBagUtils::getParameterBagValue() must be an instance of Symfony\Component\HttpFoundation\ParameterBag, instance of Symfony\Component\HttpFoundation\Request given, called in /var/www/symfony/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php on line 100" at /var/www/symfony/src/Symfony/Component/Security/Http/ParameterBagUtils.php:39 /var/www/symfony/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php:100 /var/www/symfony/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php:140 /var/www/symfony/src/Symfony/Component/Security/Http/Tests/Firewall/UsernamePasswordFormAuthenticationListenerTest.php:102 ``` Original fix in 2.7: https://github.com/symfony/symfony/pull/25657/files#diff-e07c3e5653e210d017545d47c1bd7e76R111 Commits ------- 51d9008 [Security] fix merge of 2.7 into 2.8 + add test case
…stamp in the MemcachedSessionHandler (Alessandro Loffredo) This PR was merged into the 3.4 branch. Discussion ---------- [Fix][3.4][HttpFoundation] Fix the updating of timestamp in the MemcachedSessionHandler | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT Conditions: Symfony 3.4, PHP7 and sessions handled over memcache. Apparently `memcached::touch()` returns `false` on a subsequent call with the same parameters. Since `updateTimestamp` is used in `AbstractSessionHandler::write()` ``` public function write($sessionId, $data) { if (\PHP_VERSION_ID < 70000 && $this->prefetchData) { $readData = $this->prefetchData; $this->prefetchData = null; if ($readData === $data) { return $this->updateTimestamp($sessionId, $data); } } ... ``` the result is that `write()` will return `false` on **any subsequent request within the same second** causing the following error: ``` HP Fatal error: Uncaught Symfony\Component\Debug\Exception\ContextErrorException: Warning: session_write_close(): Failed to write session data (user). Please verify that the current setting of session.save_path is correct (/var/lib/php/sessions) in Unknown:0 Stack trace: #0 [internal function]: Symfony\Component\Debug\ErrorHandler->handleError(2, 'session_write_c...', 'Unknown', 0, NULL) #1 [internal function]: session_write_close() #2 {main} thrown in Unknown on line 0 ``` Can be reproduced on `symfony/skeleton:3.4` adding the following code to `public/index.php` and performing two consecutive requests: ``` $session = $kernel->getContainer()->get('session'); $session->set("foo", "bar"); ``` Commits ------- d007469 fix the updating of timestamp in the MemcachedSessionHandler
…Handler (hjanuschka) This PR was submitted for the master branch but it was squashed and merged into the 4.0 branch instead (closes symfony#26403). Discussion ---------- fix the handling of timestamp in the MongoDBSessionHandler | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT in the process of upgrading from 3.4 to 4.0 we stumbled upon a issue with mongo session handler. ``` [05-Mar-2018 11:12:57 Europe/Vienna] PHP Fatal error: Uncaught Error: Call to undefined method Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler::createDateTime() in /opt/APP/vendor/symfony/http-foundation/Session/Storage/Handler/MongoDbSessionHandler.php:144 Stack trace: #0 [internal function]: Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler->updateTimestamp('96d983b59f8aef8...', 'user_obj|O:9:"k...') #1 [internal function]: session_write_close() #2 {main} thrown in /opt/APP/vendor/symfony/http-foundation/Session/Storage/Handler/MongoDbSessionHandler.php on line 144 ``` this PR re-add's the method, that somehow got removed in 4.0 branch, whereas the interface forces to have the implemantation. Commits ------- 97d9ea8 fix the handling of timestamp in the MongoDBSessionHandler
…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)) symfony#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 symfony#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 symfony#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 symfony#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}() symfony#3 /var/www/x/symfony/vendor/symfony/event-dispatcher/EventDispatcher.php(90): Symfony\Component\EventDispatcher\EventDispatcher->sortListeners('console.command') symfony#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}() symfony#3 /var/www/x/symfony/vendor/symfony/event-dispatcher/EventDispatcher.php(90): Symfony\Component\EventDispatcher\EventDispatcher->sortListeners('console.command') symfony#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
…ink checked method… (fjogeleit) This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [FrameworkBundle] TextDescriptor::formatControllerLink checked method… …_exists method before it ensures that $controller is not null | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Today I tried PHP8 with Symfony 5.2. - by checking my routes with ``` bin/console debug:router ``` It throws ``` method_exists(): Argument #1 ($object_or_class) must be of type object|string, null given ``` The reason is the configured auth route for the login API defined in routes.yaml: ``` authorization::login: path: '/login' ``` This route has no controller configured and the value of $controller in `TextDescriptor::formatControllerLink` in the FrameworkBundle is `null`. This method has a elseif condition with `method_exists` without a check if $controller is a string or object. In PHP8 this throws an exception/error and did not work. This PR checks that `$controller` is not null before the method_exists check to prevent this failure. I'm not sure how to test this in the existing Testsuite Commits ------- 67bd779 [FrameworkBundle] TextDescriptor::formatControllerLink checked method…
… (lyrixx) This PR was merged into the 4.4 branch. Discussion ---------- [Messenger] Fix stopwach usage if it has been reset | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | I'm slowly migrating an application to messenger (from swarrot) and I hit a strange bug. My message was well processeed **BUT** retry! It comes from two things * I manually reset the application (via the service resetter, to keep a low memory usage) * symfony/messenger try to collect some information, but since the stopwatch has been reset, an exception occurs and the message has been retried So this patch avoid throwing an exception when everything works well <details> <summary>the trace:</summary> ``` 18:45:41 INFO [messenger] Message AppBundle\Crawler\Messenger\Message\CrawlSitemapMessage handled by AppBundle\Crawler\Messenger\MessageHandler\CrawlSitemapMessageHa ndler::__invoke [ "message" => AppBundle\Crawler\Messenger\Message\CrawlSitemapMessage^ { -crawlId: "885d23a7-8ad5-4935-a2b3-1c114ac76ded" }, "class" => "AppBundle\Crawler\Messenger\Message\CrawlSitemapMessage", "handler" => "AppBundle\Crawler\Messenger\MessageHandler\CrawlSitemapMessageHandler::__invoke" ] 18:45:41 ERROR [messenger] Error thrown while handling message AppBundle\Crawler\Messenger\Message\CrawlSitemapMessage. Sending for retry #1 using 1000 ms delay. Erro r: "Event ""Symfony\Component\Messenger\Middleware\HandleMessageMiddleware" on "messenger.bus.default"" is not started." [ "message" => AppBundle\Crawler\Messenger\Message\CrawlSitemapMessage^ { -crawlId: "885d23a7-8ad5-4935-a2b3-1c114ac76ded" }, "class" => "AppBundle\Crawler\Messenger\Message\CrawlSitemapMessage", "retryCount" => 1, "delay" => 1000, "error" => "Event ""Symfony\Component\Messenger\Middleware\HandleMessageMiddleware" on "messenger.bus.default"" is not started.", "exception" => LogicException { #message: "Event ""Symfony\Component\Messenger\Middleware\HandleMessageMiddleware" on "messenger.bus.default"" is not started." #code: 0 #file: "./vendor/symfony/symfony/src/Symfony/Component/Stopwatch/Section.php" #line: 142 trace: { ./vendor/symfony/symfony/src/Symfony/Component/Stopwatch/Section.php:142 { …} ./vendor/symfony/symfony/src/Symfony/Component/Stopwatch/Stopwatch.php:126 { …} ./vendor/symfony/symfony/src/Symfony/Component/Messenger/Middleware/TraceableMiddleware.php:75 { …} ./vendor/symfony/symfony/src/Symfony/Component/Messenger/Middleware/HandleMessageMiddleware.php:83 { …} ./vendor/symfony/symfony/src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php:74 { …} ./src/Middleware/ResetApplicationMiddlerwareMiddleware.php:14 { AppBundle\Middleware\ResetApplicationMiddlerwareMiddleware->handle(Envelope $envelope, StackInterface $stack): Envelope^ › echo "couocu"; › return $stack->next()->handle($envelope, $stack); › } } ./vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/Messenger/DoctrinePingConnectionMiddleware.php:34 { …} ./vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/Messenger/AbstractDoctrineMiddleware.php:45 { …} ./vendor/symfony/symfony/src/Symfony/Component/Messenger/Middleware/FailedMessageProcessingMiddleware.php:34 { …} ./vendor/symfony/symfony/src/Symfony/Component/Messenger/Middleware/DispatchAfterCurrentBusMiddleware.php:68 { …} ./vendor/symfony/symfony/src/Symfony/Component/Messenger/Middleware/RejectRedeliveredMessageMiddleware.php:48 { …} ./vendor/symfony/symfony/src/Symfony/Component/Messenger/Middleware/AddBusNameStampMiddleware.php:37 { …} ./vendor/symfony/symfony/src/Symfony/Component/Messenger/Middleware/TraceableMiddleware.php:43 { …} ./vendor/symfony/symfony/src/Symfony/Component/Messenger/MessageBus.php:80 { …} ./vendor/symfony/symfony/src/Symfony/Component/Messenger/TraceableMessageBus.php:41 { …} ./vendor/symfony/symfony/src/Symfony/Component/Messenger/RoutableMessageBus.php:54 { …} ./vendor/symfony/symfony/src/Symfony/Component/Messenger/Worker.php:114 { …} ./vendor/symfony/symfony/src/Symfony/Component/Messenger/Worker.php:77 { …} ./vendor/symfony/symfony/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php:198 { …} ./vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:255 { …} ./vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:989 { …} ./vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:96 { …} ./vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:290 { …} ./vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:82 { …} ./vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:166 { …} ./bin/console:29 { …} } } ] ``` </details> Commits ------- bf4b0cc [Messenger] Fix stopwach usage if it has been reset
…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
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
…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
… 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
…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
… 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() symfony#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
…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
…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
…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
…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()`
…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
Hey @dmaicher, thanks for opening symfony#21288.
What do you think of those changes?