Last modified: 2014-07-26 01:40:45 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T57322, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 55322 - PreloadingGenerator does not set editRestriction
PreloadingGenerator does not set editRestriction
Status: NEW
Product: Pywikibot
Classification: Unclassified
pagegenerators (Other open bugs)
unspecified
All All
: Unprioritized normal
: ---
Assigned To: Pywikipedia bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-05 05:06 UTC by Kunal Mehta (Legoktm)
Modified: 2014-07-26 01:40 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Kunal Mehta (Legoktm) 2013-10-05 05:06:14 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.
Comment 1 Kunal Mehta (Legoktm) 2013-10-05 05:06:16 UTC
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.
Comment 2 Kunal Mehta (Legoktm) 2013-10-05 05:06:18 UTC
- **summary**: Nasty weird bug involving preloadingGenerator & canBeEdited --> PreloadingGenerator does not set editRestriction

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links