Skip to content

Conversation

@GuilhemN
Copy link
Member

@GuilhemN GuilhemN commented May 30, 2020

Sorry I am quite late at submitting changes for v3...

I think it wasn't a good idea to introduce such an handler in the first place (sorry for that) and I think it should be reworked to do just what we want it to: inherit the FlattenException handler.

As @goetas noted (a while ago now) in #1899 (comment), it has terrible performance issues and I think v3 would be a great opportunity to fix it.

I hope it's still ok for you but if not, well I missed the boat :)

@GuilhemN GuilhemN changed the base branch from master to 2.x May 30, 2020 17:37
@goetas
Copy link
Member

goetas commented May 30, 2020

I have talked to @xabbuh over slack about this:

imo should be done in a major, because with that handler you have introduced a new feature in jms 🙂
the ability to define handlers for a class based on its parent

I'm 👍 for this change, but I'm not familiar with what FlattenException is doing... so my review will not be that useful

@xabbuh
Copy link
Member

xabbuh commented May 31, 2020

I think we should not block the 3.0 release with this PR and first discuss a bit what we want to achieve here. For example, would it make sense to add an option to completely disable our custom registries (in 3.1 then)? If I don't miss anything, they are not that useful anymore.

@GuilhemN
Copy link
Member Author

would it make sense to add an option to completely disable our custom registries (in 3.1 then)

You're right they could be completely removed, in 3.x the bundle only uses instances of FlattenException.
The creation of an option would delay their removal to 4.0 but would still allow perf improvement. Its use could be encouraged through the recipe, and maybe through a deprecation notice, so I'm in favor of doing this 👍 It would also avoid unneeded pressure to finish and review this PR on time :)

I'll modify this PR accordingly then!

@xabbuh
Copy link
Member

xabbuh commented May 31, 2020

👍 sounds like a good plan

@GuilhemN GuilhemN changed the base branch from 2.x to master May 31, 2020 08:21
$options['serializeNullStrategy'] = $config['serializer']['serialize_null'];
$viewHandler->addArgument($options);

if ($config['serializer']['disable_custom_jms_registry']) {
Copy link
Member Author

@GuilhemN GuilhemN May 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether we should trigger a deprecation warning in case this option is not activated as it will create noise for the user but shouldn't make the removal of the custom registry safer (the deprecation triggered here ensures it has no effect).

@GuilhemN GuilhemN added this to the 3.1 milestone May 31, 2020
@GuilhemN GuilhemN changed the base branch from master to 3.x June 15, 2020 21:21
$handler = $this->registry->getHandler($direction, $typeName, $format);
if (null !== $handler) {
if (!$first) {
@trigger_error(sprintf('Relying on the custom registry %s to inherit the JMS handler of type `%s` is deprecated since FOSRestBundle 3.1. It will be removed in version 4.0. Use the option `fos_rest.serializer.disable_custom_jms_registry` to disable it.', __CLASS__, $typeName), E_USER_DEPRECATED);
Copy link
Member

@xabbuh xabbuh Jul 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure this deprecation will always be triggered? I could imagine that's not the case if $first never becomes false. I tend to think that triggering a deprecation when the option is set to false would be the better approach. Deprecating this class is not really necessary (at least not triggering a deprecation) as it is already marked as internal.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the deprecation is not triggered it is either because

  • The handler returned is the one expected (the one returned by the jms registry)
  • No handler is returned and the behavior is thus the same as the jms registry

I wanted to deprecate is relying on the behavior of this class, so as long as the result is the same as what would jms return I believe it's ok to not trigger a deprecation.
But if we want to warn users they could improve performance by disabling this class, triggering a deprecation when $first would indeed be legit.

So in my opinion it depends whether we want to warn users about the performance improvement possibility or not. I think it is better to privilege DX but I would appreciate having your opinion on this point :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should always trigger the deprecation to make users aware of the performance penalty this may have.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, it's updated :)

@GuilhemN
Copy link
Member Author

The travis failure is quite strange, I don't think it's related to this PR.

UPGRADING-3.0.md Outdated
* `FOS\RestBundle\View\View`
* `FOS\RestBundle\View\ViewHandler`

* The JMS Handlers `JMSHandlerRegistry` and `JMSHandlerRegistryV2` behaviors have changed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GuilhemN I guess this should be moved to the CHANGELOG instead since 3.0 has already been released

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, updated

@goetas
Copy link
Member

goetas commented Oct 11, 2021

closing in favor of #2319 for jms/serializer-bundle v4

@goetas goetas closed this Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants