Fosuserbundle: Deprecation with Symfony 4.1 - AbstractToken::hasUserChanged

Created on 30 May 2018  Â·  8Comments  Â·  Source: FriendsOfSymfony/FOSUserBundle

Updated Symfony components to 4.1 and got following deprecation:

User Deprecated: Checking for the AdvancedUserInterface in Symfony\Component\Security\Core\Authentication\Token\AbstractToken::hasUserChanged has been deprecated in 4.1.

Implement the Symfony\Component\Security\Core\User\EquatableInterface to check if the user has been changed

Most helpful comment

@enrico69 The problem appears to have been addressed but only in preparation for Symfony 5, and not to get rid of the deprecation notice(s).

From UserInterface.php

// This is required to support apps that explicitly check if a user is an instance of AdvancedUserInterface
if (interface_exists('\Symfony\Component\Security\Core\User\AdvancedUserInterface')) {
    /**
     * @author Thibault Duplessis <[email protected]>
     * @author Johannes M. Schmitt <[email protected]>
     *
     * @deprecated since Symfony 4.1. Remove in Nov 2023 (End of support for security fixes SF 4.4)
     */
    interface UserInterface extends FosUserInterface, \Symfony\Component\Security\Core\User\AdvancedUserInterface
    {
    }
} else {
    /**
     * @author Thibault Duplessis <[email protected]>
     * @author Johannes M. Schmitt <[email protected]>
     * @author Julian Finkler <[email protected]>
     */
    interface UserInterface extends FosUserInterface, BaseUserInterface, EquatableInterface
    {
    }
}

Since symfony didn't actually _delete_ the AdvancedUserInterface class yet, the if block will always result in true until that Interface is actually _gone_. A bit annoying, but whatever.

All 8 comments

Got the same deprecation.

That cannot to be fixed by compatibility problems with older symfony versions

Should be solved with https://github.com/FriendsOfSymfony/FOSUserBundle/pull/2815

EDIT:
Ok, I need to implement the EquatableInterface

EDIT2:
Done ✔

I still have the issue.
To workaround it I made my User entity implements _EquatableInterface_ but I don't know it is normal as I understand that it is supposed to be fixed? Am I wrong?

I have the same issue.

@enrico69 The problem appears to have been addressed but only in preparation for Symfony 5, and not to get rid of the deprecation notice(s).

From UserInterface.php

// This is required to support apps that explicitly check if a user is an instance of AdvancedUserInterface
if (interface_exists('\Symfony\Component\Security\Core\User\AdvancedUserInterface')) {
    /**
     * @author Thibault Duplessis <[email protected]>
     * @author Johannes M. Schmitt <[email protected]>
     *
     * @deprecated since Symfony 4.1. Remove in Nov 2023 (End of support for security fixes SF 4.4)
     */
    interface UserInterface extends FosUserInterface, \Symfony\Component\Security\Core\User\AdvancedUserInterface
    {
    }
} else {
    /**
     * @author Thibault Duplessis <[email protected]>
     * @author Johannes M. Schmitt <[email protected]>
     * @author Julian Finkler <[email protected]>
     */
    interface UserInterface extends FosUserInterface, BaseUserInterface, EquatableInterface
    {
    }
}

Since symfony didn't actually _delete_ the AdvancedUserInterface class yet, the if block will always result in true until that Interface is actually _gone_. A bit annoying, but whatever.

@jsfgreen Thanks

Is there any update on this issue or do we just need to live with this deprecation warning until either Symfony\Component\Security\Core\User\AdvancedUserInterface has been deleted from the Symfony project or this if statement has been removed from the FOSUserBundle?

It's no huge deal, but this is the last deprecation notice in my application after an upgrade from Symfony 3.4 to 4.4 and it would be nice to clear them all up.

Was this page helpful?
0 / 5 - 0 ratings