It was only checking for the identifier, but the type has to be equivalent as well.
I am not familiar with this code.
Maybe @Brecht Van Lommel (brecht) knows it better?
At first glance it seems to be the right solution.
Apparently this function is only called when the node changes its type.
And sockets of different types can have the same identifier.
But another effect of this change is that it will "unlink" the socket.
I don't know if it is intentional to keep sockets with the same identifier linked (regardless of type).
If this is the case, the ideal would be to change the type.