You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HUGE [BUG]: Custom subscribing handlers get overwritten in JMS\SerializerBundle\DependencyInjection\Compiler\CustomHandlersPass::sortAndFlattenHandlersList() and thus never called!
#853
Open
yyaremenko opened this issue
May 11, 2021
· 4 comments
As you can see, our custom handler is there. Fine.
4. In the same method, right before the return statement, dump the handlers once again to check if our custom handler is still there
So if we have two - three - whatever number of handlers for a specific direction + type + format (in our case, 'serialize' + 'DateTime' + 'json'), onlly the last handler in the list gets registered, each previous handler gets rewritten by the next one in the list (and, in our case, our custom handler is rewritten by jms_serializer.datetime_handler).
The text was updated successfully, but these errors were encountered:
@nnmer Yes, I thought of this workaround, thank you. I still believe though the bundle must work without any workarounds out of the box, or at least have corresponding notice in the documentation. Also, if you have several custom subscribing methods for the same specific direction + type + format, with different priorities --> only one of such handlers will be taken into consideration.. You'll see no warnings / notices and will waste a ton of time figuring out why only one of your handlers works.
yyaremenko
changed the title
HUGE BUG: Custom subscribing handlers get overwritten in JMS\SerializerBundle\DependencyInjection\Compiler\CustomHandlersPass::sortAndFlattenHandlersList() and thus never called!
HUGE [BUG]: Custom subscribing handlers get overwritten in JMS\SerializerBundle\DependencyInjection\Compiler\CustomHandlersPass::sortAndFlattenHandlersList() and thus never called!
May 30, 2021
I think that the best thing to do here is to have built-in handlers to run with a lower priority than the user defined one, in this way there is no need to use the workaround.
@yyaremenko fee free to send a pull request for such change
Steps required to reproduce the problem
(Symfony 5.x)
Expected Result
The code dies with 'HERE';
Actual Result
Nothing happens.
Reason.
JMS\SerializerBundle\DependencyInjection\Compiler\CustomHandlersPass::sortAndFlattenHandlersList()
For this, add the following code to the very beginning of the sortAndFlattenHandlersList() method
Most probably, you'll get
As you can see, our custom handler is there. Fine.
4. In the same method, right before the return statement, dump the handlers once again to check if our custom handler is still there
And what you get is
OUR CUSTOM HANDLER IS GONE.
Why? Obviously because during 'flattering' in the sortAndFlattenHandlersList() method what happens is
So if we have two - three - whatever number of handlers for a specific direction + type + format (in our case, 'serialize' + 'DateTime' + 'json'), onlly the last handler in the list gets registered, each previous handler gets rewritten by the next one in the list (and, in our case, our custom handler is rewritten by jms_serializer.datetime_handler).
The text was updated successfully, but these errors were encountered: