-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Cache key "email@address" contains reserved characters {}()/\@: #26313
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
Comments
can you dump the full stack trace of that exception please? |
|
We'd need to know where the invalid key is used. |
echoing new exception just before
|
Are you sure you put that echo inside the "if"? The trace tells about key |
Yes, echo exception is within this |
For some reason, the metadata factory in the Validator component is called with an e-mail address which is then treated as a class name there. Would you be able to provide a small example application that allows to reproduce your issue? |
Source code or as www? |
The source code :) The best is a small application that you push to GitHub. |
Repo, cut to minimum: https://github.com/dadepl/sfusertest |
Are you sure that you cleared the cache properly? |
If by "properly" you mean running |
@xabbuh could this be the problem? https://github.com/dadepl/sfusertest/blob/master/src/Company/AppBundle/Entity/User.php#L40 So somehow it treats the email as an object and tries to get the metadata for it? 🙈 @dadepl what if you change that to |
@dmaicher Thanks! It helped when I removed Thanks one more time! |
@dmaicher Great catch 👍 not sure though why this didn't fail for me. So this does not look like an error in the Cache component, but we need to investigate why using the |
@xabbuh I checked a bit and actually here The Validator just passes any scalar value and treats it as an object. So it tries to fetch the meta data here: And the value is then passed through to the |
Maybe i could have a try for my first issue? |
@pmontoya That would be great! 👍 |
Ok, it's for me! 🤞 |
the escaping is done assuming the fact that metadata are loaded for a class name, which cannot contain a but the symfony/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php Line 98 in ee51f74
|
@stof indeed 👍 Should be fine to move this check before trying to retrieve something from the cache then |
…for non classname if tested values isn't existing class (Pascal Montoya, pmontoya) This PR was merged into the 2.7 branch. Discussion ---------- [Validator] Fix LazyLoadingMetadataFactory with PSR6Cache for non classname if tested values isn't existing class | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #26313 | License | MIT If @Assert\Valid is applied to a string value, the value is searched in metadata cache and some characters aren't allowed in this cache. This create an unexpected exception. Class existence is now tested before cache read. Commits ------- 5198f43 Disable autoloader call on interface_exists check cd91420 [Validator] Fix LazyLoadingMetadataFactory with PSR6Cache for non classname if tested values isn't an existing class
This issue happens again. Symfony cli version 5.4.7 My composer.json contains: PHP Version: 7.4 Cache and log dirs were deleted. Point of my code where this error starts: Point of my code where this message is showed: How could I solve this issue, please? Best regards. |
This is probably related to an update of Doctrine packages. You now need to access the repository using the FQCN instead of the alias like this: $user = $em->getRepository(User::class)->findOneBy(['email' => $email); |
Thanks, Christian. @xabbuh |
Hi,
I have problem when submitting user form. I use FOSUserBundle and there's simple form with only two fields:
->add('name', TextType::class, [ 'label' => 'name and surname', ])
->add('department', TextType::class, [ 'label' => 'department', ])
It's also standard in controller:
$editForm = $this->createForm('Company\AdminBundle\Form\UserEditType', $user);
$editForm->handleRequest($request);
When I submit form in production env I get error in prod.log:
[2018-02-26 08:50:35] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Cache\Exception\InvalidArgumentException: "Cache key "email@address" contains reserved characters {}()/\@:" at /Users/local/Sites/projectname/vendor/symfony/cache/CacheItem.php line 162 {"exception":"[object] (Symfony\\Component\\Cache\\Exception\\InvalidArgumentException(code: 0): Cache key \"email@address\" contains reserved characters {}()/\\@: at /Users/local/Sites/projectname/vendor/symfony/cache/CacheItem.php:162)"} []
As far as I can check, the problem occurs on
handleRequest($request)
in controller and later on SymfonyForm
class when dispatchesPOST_SUBMIT
$dispatcher->dispatch(FormEvents::POST_SUBMIT, $event);
and then in
ValidationListener
class when running$violations = $this->validator->validate($form);
I do not use any custom cache bundles / vendors and it's first time I have such problem. Just don't know why. I understand error itself, that there's problem with "
@
" character in cache and with PSR-6, but have no idea what to check or change.Thank you for help.
The text was updated successfully, but these errors were encountered: