mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Cache id "[*_1 1][2]" contains unauthorized character " " #6424
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sjurajpuchky on GitHub (Mar 10, 2020).
Bug Report
When I use doctrine with Symfony 4.3 and second level cache with Memcached
this error appears
Cache id "[*_1 1][2]" contains unauthorized character " "
after a few investigations, I found bug and solution
Summary
vendor/doctrine/orm/lib/Doctrine/ORM/Cache/EntityCacheKey.php
On line 55:
$this->hash = str_replace('\', '.', strtolower($entityClass) . '_' . implode(' ', $identifier));
Current behavior
You can't use implode with space delimiter since space delimiter is unauthorized character in ID.
How to reproduce
Symofony 4.3 with second level cache enabled memcached used
Expected behavior
Cache Key Id can't contains " " space character
it's any possibility to add this fix to next release?
Fix
Fix:
$this->hash = str_replace('\', '.', strtolower($entityClass) . '_' . implode('-', $identifier));
@asamats commented on GitHub (Mar 13, 2020):
I think that
_will be better.@sjurajpuchky commented on GitHub (Mar 13, 2020):
_ is already used for delimiting className and key
@SenseException commented on GitHub (Mar 13, 2020):
@sjurajpuchky Would you like to open a pull request with your fix? It would be much appreciated.
@sjurajpuchky commented on GitHub (Mar 13, 2020):
@SenseException go ahead :)
@beberlei commented on GitHub (Mar 15, 2020):
@SenseException what key should we pick? i propose
;#or=- something that is unlikely a character in a string based id, which both-and_could easily be.Something really save from conflicts with two string based composite ids is wrapping in []:
@sjurajpuchky commented on GitHub (Mar 15, 2020):
@beberlei it should be, but sounds better
$this->hash = str_replace('\\', '.', strtolower($entityClass) . '_[' . implode('][', $identifier) . ']');@SenseException commented on GitHub (Mar 15, 2020):
I can even think about using
$. I would expect that character only when a variable in a string wasn't handled correctly by a developer.@lcobucci commented on GitHub (Mar 16, 2020):
I'd suggest following the guidelines in https://www.php-fig.org/psr/psr-16/:
@sjurajpuchky commented on GitHub (Mar 30, 2020):
@SenseException pull request created
@vaclav-cerny commented on GitHub (Nov 28, 2022):
Hi, is there any solution for this?