Page MenuHomePhabricator

Don't try to login during logout
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue:

Try to logout if you are already logged out

D:\pwb\GIT\core>pwb login -logout
WARNING: No user is logged in on site wikipedia:de
Password for user Xqtest on wikipedia:de (no characters will be shown):
Logging in to wikipedia:de as Xqtest
Logged out of wikipedia:de.
D:\pwb\GIT\core>pwb shell
Welcome to the Pywikibot interactive shell!
>>> site = pywikibot.Site()
>>> site.logged_in()
False
>>> site.logout()
WARNING: No user is logged in on site wikipedia:de
Password for user Xqtest on wikipedia:de (no characters will be shown):
Logging in to wikipedia:de as Xqtest
>>> site.logged_in()
False
>>>

What happens here?:
API:Logout needs a token (see also T222508). To get the token a login() is made after rPWBCc4fbf0c if necessary.

If you are logged in a logout() works as expected:

>>> site = pywikibot.Site()
>>> site.logged_in()
False
>>> site.login()
WARNING: No user is logged in on site wikipedia:de
Password for user Xqtest on wikipedia:de (no characters will be shown):
Logging in to wikipedia:de as Xqtest
>>> site.logged_in()
True
>>> site.logout()

What should have happened instead?:
No login() should be made during logout()

Software version (skip for WMF-hosted wikis like Wikipedia):
Pywikibot 3.0.20190722+

Event Timeline

Xqt triaged this task as Medium priority.Jan 10 2023, 7:10 AM

Change #1018821 had a related patch set uploaded (by Ericpien; author: Ericpien):

[pywikibot/core@master] [FIX] Skip process that requires login to logout

https://gerrit.wikimedia.org/r/1018821

@ericpien: thanks a lot for your patch. We have to check it against T222508 but I assume it works as expected. Thanks again.

Change #1018821 merged by jenkins-bot:

[pywikibot/core@master] [FIX] Skip process that requires login to logout

https://gerrit.wikimedia.org/r/1018821