-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Query Cache mangled if saved by-reference #6552
Conversation
We can probably solve this by cloning the |
I disagree: we have in production many long-running processes where this kind of cache is enough and more performant than the alternatives |
I mean, you do you, but you're like asking for the kind of trouble that you see here. No other cache would behave this way. What you call "the by-reference tecnique" is simply put non-standard behavior. |
Thank you. |
* 4.3.x: Create stubs instead of mocks (#6564) [Bug] Query Cache mangled if saved by-reference (#6552) test: remove ->expects(self::any()) Fix typo in PostgreSql documentation reference fix Acknowledge the existence of 3.10 (#6553) Simplify tracking implicitly created indexes Remove handling unuique constraint column names as associative array (#6549) test: cover nested transactions
Bug emerged in #6510 (comment)
The current implementation of query cache relies on the cache not saved by-reference; the bug has never been seen before because by default
new ArrayAdapter()
saves the cache with serialization, hence breaking the by-reference pointer.Once the by-reference tecnique is used, two issues pop up:
\Doctrine\DBAL\Cache\ArrayResult::$num
is never reset, so once it gets incremented in the first\Doctrine\DBAL\Cache\ArrayResult::fetch
call, the following calls will always fail$num
property reset, a manual call on\Doctrine\DBAL\Result::free
will by cascade call the\Doctrine\DBAL\Cache\ArrayResult::free
method erasing all the saved resultsI think that the
ArrayResult
implementation is not the culprit, but rather the #6510 giving to the cache backend the internal object by reference instead of giving it a copy.