Page MenuHomePhabricator

force login after performing a sysop action
Closed, ResolvedPublic

Description

Originally from: http://sourceforge.net/p/pywikipediabot/bugs/1632/
Reported by: nu11zer0
Created on: 2013-05-03 05:54:46
Subject: force login after performing a sysop action
Assigned to: russblau
Original description:
After my bot performed a sysop action, then wrote to a page, the bot wrote without botflag\! It seems that the framework cached some informations and understood that the bot has no flag. My workaround is to add "site.login\(\)" after every sysop action. But it should be implemented in the framework. Note that now redirect.py also has this problem.

\----
Pywikibot branches/rewrite/ \(r11487, 2013/05/02, 07:59:55, ok\)
Python 2.7.3 \(default, Sep 26 2012, 21:53:58\)
\[GCC 4.7.2\]
unicode test: ok


Version: unspecified
Severity: normal
See Also:
https://sourceforge.net/p/pywikipediabot/bugs/1632
https://bugzilla.wikimedia.org/show_bug.cgi?id=55066

Details

Reference
bz55140

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 2:22 AM
bzimport added a project: Pywikibot-General.
bzimport set Reference to bz55140.
bzimport added a subscriber: Unknown Object (????).
Legoktm created this task.Oct 5 2013, 4:31 AM

I'm also have similar problem.

After updating pywikibot framework, forcing login is somewhat strange.

When bot name differ by project \(E.g, different name for local wiki and meta/commons wiki\), login is requested for local bot name in meta wiki.

\------------------------------------------------------------------------
Pywikibot \[http\] branches/rewrite \(r11617, 2013/06/02, 13:07:05, OUTDATED\)
Python 2.6.5 \(r265:79063, Oct 1 2012, 22:04:36\)
\[GCC 4.4.3\]
unicode test: ok

jayvdb set Security to None.

Was this your ticket @Nullzero?

Yes, but I will not be able to contribute to Pywikibot for a while. Feel free to take over my patches, bugs, etc.

The current design of pywikibot is that it always uses the sysop account only for actions which require sysop capabilities. It uses the bot account for everything else. T71283 is considering to change that design.

My understanding of this problem is

  1. pywikibot logs into site with the non-sysop account, that has the 'bot' flag, maybe does an edit which is a 'bot' edit.
  2. pywikibot logs into site with the sysop account, that does not have the 'bot' flag.
  3. pywikibot edit using non-sysop account should be marked as a 'bot' edit ('b' in recent changes), .. however the edit isnt marked as a bot edit, and that is this bug.

In step 2, the site object does not keep the login credentials of the non-sysp account. T67196
In step 3, the site object should re-login automatically using non-sysop username and password in config.password_file.

VcamX added a subscriber: VcamX.Feb 20 2015, 10:06 AM

@jayvdb @Nullzero this is my test script for reproducing the bug, but the results showed it works well. Maybe I still didn't get your point...

VcamX added a comment.Feb 20 2015, 2:37 PM

@jayvdb @Nullzero I found there's a decorator must_be in modul pywikibot/site, which limit the user status when functions are called. In my option, it may solve the bug since it checks the user status before the decorated function runs.

If I don't misremember, the problem arises when I run two scripts simultaneously. Suppose two scripts are A and B, with A performing sysop actions (without botflag) and B performing bot actions (with botflag). It seems that some settings about botflag are shared somehow, so frequently B doesn't use botflag to edit. Thus edits appear in recentchanges.

VcamX added a comment.EditedFeb 22 2015, 3:48 AM

@Nullzero How do these two scripts running simultaneously? Use cron to set a interval of running? Or just run them one by one? Did these two scripts run under the same directory (did they share the same pywikibot.lwp) ? Update: I may probably get your point. I'm able to reproduce this bug. Thanks for your help :)

VcamX added a comment.Feb 22 2015, 5:29 AM

@jayvdb @Nullzero I found out what causes this bug.
When we do an edit, the parameter botflag of function save in pywikibot-core/page will decide whether this edit will have botflag or not. This line will check the user right. If A performing sysop action first, it will cached sysop cookie in pywikibot.lwp. Then B performing a bot action without executing like site.login() first and doing an edit, the botflag will be set as false since the pywikibot will check user right using sysop cookie, and of course there's no bot in site.userinfo['rights']. Although we have decorator must_be for editpage (see this) which will check the user when doing an edit. The botflag is set as false before the decorator must_be works.

Change 192178 had a related patch set uploaded (by VcamX):
Postpone botflag checking in Page

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

Patch-For-Review

Change 192178 merged by jenkins-bot:
Postpone botflag checking in Page

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

jayvdb closed this task as Resolved.May 8 2015, 7:08 AM
jayvdb assigned this task to VcamX.