LoginSignupSpecialPage::successfulAction() is used both after a successful login, and when visiting the login page while already logged in. That method calls the UserLoginComplete hook, so it will sometimes be invoked in situations which have nothing to do with a login. rMW3617c982c9db: Use AuthManager on special pages added the $direct parameter to differentiate, but it would have been better to just remove the $direct === false case, I don't think it's meaningful.
Tangentially related: that patch removed the "cookie redirect check" step from login, but didn't remove the $wgDisableCookieCheck variable. It probably should have.