mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Cache: READ_WRITE failing Argument 2 passed to...
#6384
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 @NikoGrano on GitHub (Jan 14, 2020).
Bug Report
Summary
Entity:
Configuration (Bundle for Symfony)
While correct configuration would be
Current behavior
Running a write into the database will cause
Digging the issue
So this is caused due here we are expecting Region interface. This is propably correct functionality. Here we pass it to the next class, which causes this error. The problem is, in the Persister constructor we are declaring we want this one specific type.
This should be fixed with a interface, abstract class or something. Any toughts? Or is this something for 3.0/wontfix?
How to reproduce
Configure previous settings and try persist something to the database.
Expected behavior
Throw a handled exception, not a type error.
Notes
I'm not sure how this architecture fully works, so I would like if somebody else familiar with this would take this. With correct configuration this works, but I wasn't sure if I should post bug about this, however I decided to post it just to make sure this is intended functionality.
@lcobucci commented on GitHub (Jan 14, 2020):
@NikoGrano did you manage to reproduce this using the ORM only? This seems to be an integration (or configuration) issue since the code that creates the decorator seems to be bypassed...
04036f2244/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php (L178-L188)@NikoGrano commented on GitHub (Jan 15, 2020):
Hey!
I agree on that this is more configuration error on bundle side, than a issue. However, I think there should be
\LogicExceptionthrown always instead of hard debuggable type-error.The previous code you linked, it gets by passed due the region is set by using following method. Then after in second block, we are trying to get region, however, due it is already set, it will take it from the regions array instead of creating a new one.
04036f2244/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php (L72-L75)04036f2244/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php (L109-L117)04036f2244/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php (L164-L171)So setting a region with
setRegionis correct usage. However, the givenDefaultRegionis valid based on the interface, but it is not valid in case ofREAD_WRITEaction, due it does requireConcurrentRegion.04036f2244/lib/Doctrine/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersister.php (L16-L27)Adding a check
instaceofcheck here would fix this and make debugging much easier, but is it correct approach? More worried about that.04036f2244/lib/Doctrine/ORM/Cache/DefaultCacheFactory.php (L123-L125)@NikoGrano commented on GitHub (Jan 15, 2020):
Checking this futher, for example I would propose following patch for this:
See #7984
I would request comments for this. If it's fine, I will create UnitTests.
@NikoGrano commented on GitHub (Jan 17, 2020):
@lcobucci Sorry for pining. Does this look a good solution, worth of continuing working on PR?
@lcobucci commented on GitHub (Jan 18, 2020):
@NikoGrano the problem is that (as far as I remember) this method is used in places where performance is needed and adding any additional check might mess that up.
I do agree that the design is fragile, though.
@NikoGrano commented on GitHub (Jan 18, 2020):
@lcobucci I was worrying about exactly about same. Maybe we should check if the flow changes in 3.0 or close in as "Won't Fix" and Known Issue. It is anyways configuration issue.
Anyways, when somebody sees this issue in future, he/she can work the solution based on this issue.
@andreybolonin commented on GitHub (Dec 7, 2021):
@lcobucci the same error
@NikoGrano commented on GitHub (Dec 7, 2021):
Still would recommend implementing #7984 or something similar to avoid pings like this. Clear error what you are doing wrong instead of type error makes stuff easier to figure out.
@lcobucci commented on GitHub (Dec 7, 2021):
@andreybolonin please send a patch that fixes without introducing performance issues. I'm pretty sure that @greg0ire and the other folks from the ORM team will be happy to help out.
@NikoGrano commented on GitHub (Nov 25, 2024):
Closed as stale.