Last modified: 2014-07-26 01:40:45 UTC
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.
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.
- **summary**: Nasty weird bug involving preloadingGenerator & canBeEdited --> PreloadingGenerator does not set editRestriction