https://bugzilla.wikimedia.org/show_bug.cgi?id=55322
Web browser: --- Bug ID: 55322 Summary: PreloadingGenerator does not set editRestriction Product: Pywikibot Version: unspecified Hardware: All OS: All Status: NEW Severity: normal Priority: Unprioritized Component: General Assignee: Pywikipedia-bugs@lists.wikimedia.org Reporter: legoktm.wikipedia@gmail.com Classification: Unclassified Mobile Platform: ---
Originally from: http://sourceforge.net/p/pywikipediabot/bugs/680/ Reported by: nicdumz Created on: 2008-04-23 09:09:47 Subject: PreloadingGenerator does not set editRestriction Original description: I realized that sometimes, in blockpageschecker.py, someTotalProtectedPage.canBeEdited() would wrongly return True (I have no sysop account, hence on every [edit=sysop] protected page, it should return False)
I first tried the single canBeEdited() on that total protected page : >>> import wikipedia; s = wikipedia.Site('fr', 'wikipedia'); protectedpage = wikipedia.Page(s, 'Zentrum') Checked for running processes. 1 processes currently running, including the current process. >>> protectedpage.canBeEdited() Getting 1 pages from wikipedia:fr... False
Which is fine.
However :
>>> import wikipedia; s = wikipedia.Site('fr', 'wikipedia'); protectedpage = wikipedia.Page(s, 'Zentrum') Checked for running processes. 1 processes currently running, including the current process. >>> import pagegenerators; gen = pagegenerators.PreloadingGenerator([protectedpage]) >>> for p in gen : print p.canBeEdited() ... Getting 1 pages from wikipedia:fr... True >>> protectedpage.canBeEdited() True
Which is wrong.
I then thought then calling canBeEdited on a total protected page from PreloadingGenerator would _every_time_ return wrongly True, but I was wrong :
>>> import wikipedia; s = wikipedia.Site('en', 'wikipedia'); protectedpage = wikipedia.Page(s, 'Wikipedia:site support') Checked for running processes. 1 processes currently running, including the current process. >>> import pagegenerators; gen = pagegenerators.PreloadingGenerator([protectedpage]) >>> for p in gen : print p.canBeEdited() ... Getting 1 pages from wikipedia:en... False
So apparently, in some special cases, calling canBeEdited on a total protected page from PreloadingGenerator returns True. However I have not been able to find *when* exactly this happens.
Any thoughts ?
PS : An easy fix for this is to get rid of the current implementation of canBeEdited, to use instead the new getRestrictions using the API (getRestrictions()['edit']). But we should find out what is happenning here, since we might miss something important.
https://bugzilla.wikimedia.org/show_bug.cgi?id=55322
--- Comment #1 from Kunal Mehta (Legoktm) legoktm.wikipedia@gmail.com --- Logged In: YES user_id=855050 Originator: NO
The reason for this is that PreloadingGenerator calls wikipedia.getAll(), which uses the wiki's [[Special:Export]] page to retrieve the page(s); the data structure returned by [[Special:Export]] does not include the protection status, so it is impossible to determine whether a preloaded page is protected. The only way I can see to fix this within the existing framework is to have canBeEdited() call self.get(force=True) instead of just self.get(), but that would completely defeat the purpose of preloading the pages. The other alternative is your suggestion of using the API, but this would break backwards-compatibility for many wiki families, and I think that is better addressed in the rewrite branch.
https://bugzilla.wikimedia.org/show_bug.cgi?id=55322
--- Comment #2 from Kunal Mehta (Legoktm) legoktm.wikipedia@gmail.com --- - **summary**: Nasty weird bug involving preloadingGenerator & canBeEdited --> PreloadingGenerator does not set editRestriction
https://bugzilla.wikimedia.org/show_bug.cgi?id=55322
Kunal Mehta (Legoktm) legoktm.wikipedia@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://sourceforge.net/p/p | |ywikipediabot/bugs/680
https://bugzilla.wikimedia.org/show_bug.cgi?id=55322
Amir Ladsgroup ladsgroup@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |ladsgroup@gmail.com Component|General |pagegenerators
pywikipedia-bugs@lists.wikimedia.org