Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Serializer] Add ->hasCacheableSupportsMethod() to CacheableSupportsMethodInterface#27105
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
teohhanhui commentedApr 30, 2018
It's really weird for an interface called |
nicolas-grekas commentedApr 30, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@teohhanhui why not a new name indeed. Do you have a suggestion? Naming is hard :) About a separate interface, I don't understand what you're suggesting. One interface is enough, isn't it? |
emodric commentedApr 30, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@nicolas-grekas Apart from the typo ( What is your aim here? Should I implement this interface in my normalizers and return |
nicolas-grekas commentedApr 30, 2018
What does "doesn't work" mean? My aim it at making the cacheable mechanism BC, by making it opt-in. |
emodric commentedApr 30, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
It means, my normalizers are still not used and serialization falls back to |
nicolas-grekas commentedMay 1, 2018
@emodric I fail to understand why. Can you debug the situation after applying this PR please? |
dunglas commentedMay 1, 2018
Can’t we mark |
emodric commentedMay 1, 2018
I'll try. Give me a couple of days. |
teohhanhui commentedMay 1, 2018
I think there's a much simpler and BC-safe way of doing this. Have subclasses of the built-in normalizers that implement the new interface. Then it's truly opt-in and has no potential of any BC breaks. |
teohhanhui commentedMay 1, 2018
And we could of course use them by default in the declared services. |
dunglas commentedMay 1, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@teohhanhui we had this idea, but it only fixes the problem when using the component directly. |
dunglas commentedMay 1, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@emodric can you provide the code of your custom normalizer (even privately, using a private Gist for instance, or PM on Slack)? Does it extend a builtin normalizer, or the |
emodric commentedMay 1, 2018
I'm not near a computer today, but as soon as I'm back, I'll do it. I'll try to create a test app to provoke the issue, too. In the meantime, my normalizers implement
|
teohhanhui commentedMay 1, 2018
How so? Liskov Substitution Principle means we can substitute them with any subclasses any time, no? |
nicolas-grekas commentedMay 1, 2018
@teohhanhui what is not truly opt-in in the current PR? Also, where is the potential BC break? Please advise I don't understand. Also, how would you handle the ArrayNormalizer case (see attached patch for the way this PR does it?) Would you mind opening a PR embedding your proposal? It might be easier to understand each other this way. Thanks. |
dunglas commentedMay 1, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Unfortunately we cannot rely on it to replace Symfony native services. If the user uses |
sroze left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
👍 (I understand the reluctance for such thing but don't see any better way to solve the problem)
teohhanhui commentedMay 1, 2018
That really is the fault of the client code, or does the Symfony BC promise even cover that? :x |
emodric commentedMay 1, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@dunglas Here's a Symfony Standard app (it was easier to setup this way, rather than using Flex) with@nicolas-grekas Run the app with the built in server with The output is |
nicolas-grekas commentedMay 1, 2018
@emodric thanks for the reproducer, it definitely helped, this is now fixed! |
| $this->normalizerCache[$format][$type][$k] =true; | ||
| return$normalizer; | ||
| break; |
nicolas-grekasMay 1, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This was the bug spotted by@emodric: we cannot return here, as the non-cacheable normalizers weren't checked yet.
emodric commentedMay 2, 2018
Thanks@nicolas-grekas ! Tested it with my test suite and now it works 👍 |
teohhanhui commentedMay 2, 2018
What about: VarySupportsNormalizerInterface
(So that there's more granular control and we can cache separately for normalization / denormalization?) VarySupportsSerializerInterface
|
dunglas commentedMay 2, 2018
Actually, we need to add different interfaces for Normalizers and Denormalizers. |
nicolas-grekas commentedMay 2, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Talking on Slack with@dunglas, here is the plan we have in mind:
This way, we have the best flexibility for all cases. About the name here, despite the proposal (thanks for it), I'd still keep this PR as is. PR ready on my side. |
teohhanhui commentedMay 2, 2018
The name |
dunglas commentedMay 3, 2018
Thank you@nicolas-grekas. |
…heableSupportsMethodInterface (nicolas-grekas)This PR was merged into the 4.1-dev branch.Discussion----------[Serializer] Add ->hasCacheableSupportsMethod() to CacheableSupportsMethodInterface| Q | A| ------------- | ---| Branch? | master| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | -| License | MIT| Doc PR | -Enhances the interface introduced in#27049 to make it possible to dynamically define if "supports" methods are cacheable.Commits-------04b3692 [Serializer] Add ->hasCacheableSupportsMethod() to CacheableSupportsMethodInterface
dunglas commentedMay 3, 2018
@teohhanhui can you propose a better name in a new PR? |
Enhances the interface introduced in#27049 to make it possible to dynamically define if "supports" methods are cacheable.