-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
3.0 counter cache error with lambda counters #4846
Conversation
Do we really need to add the boolean $original to the callable ? Maybe we can just return the count pending on the $entity->getOriginal() ? Anyway I missed that case, thank's for noticing 👍 😉 |
The callable is being called twice (Once to update the new foreign_key, and second to update the original foreign_key). I don't think there is another way to determining which time is being called without adding a new argument? |
Forgot my comment. I though we could check if it's an update by checking differences between |
Looks good to me. |
@antograssiot - I think that might actually work since the Entity object itself is not actually saved. Will quickly give it a test. |
@antograssiot Sorry, it obviously won't work. get('foo') and getOriginal('foo') will always be different if foo has been changed. |
@dakota Yeah I know I give it a try yesterday and couldn't find a working way. Sorry if I made you waste some time by not beeing clear about previously digging into this it's good to merge to me, thank's again 👍 |
No worries, was a quick check :) |
3.0 counter cache error with lambda counters
Thanks 👍 |
When using counterCache with a lambda counter, it would error if the entity foreign_key is updated as it was calling _getCount() with the lambda (and _getCount expects an array)
I added in a $original argument to the counterCache callable to determine what part of the count is being called.