Last modified: 2014-11-10 22:41:09 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 T57158, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 55158 - getFileVersionHistory doesn't work if information is hidden
getFileVersionHistory doesn't work if information is hidden
Status: NEW
Product: Pywikibot
Classification: Unclassified
General (Other open bugs)
compat-(1.0)
All All
: Unprioritized major
: ---
Assigned To: Pywikipedia bugs
: testme
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-05 04:35 UTC by Kunal Mehta (Legoktm)
Modified: 2014-11-10 22:41 UTC (History)
2 users (show)

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


Attachments

Description Kunal Mehta (Legoktm) 2013-10-05 04:35:04 UTC
Originally from: http://sourceforge.net/p/pywikipediabot/bugs/1550/
Reported by: stefan2wiki
Created on: 2012-12-14 01:38:42
Subject: getFileVersionHistory doesn't work if information is hidden
Original description:
Take a file where some information is hidden, for example this one:
https://commons.wikimedia.org/wiki/File:Catania\_Piazza\_Quattro\_Canti.jpg
In this case, the edit summary for the first revision is missing.

Try this code:

import wikipedia
site = wikipedia.getSite\(u'commons', u'commons'\)
page = wikipedia.ImagePage\(site, u'File:Catania Piazza Quattro Canti.jpg'\)
history = page.getFileVersionHistory\(\)

I get an error message:

Traceback \(most recent call last\):
File "<stdin>", line 1, in <module>
File "wikipedia.py", line 4194, in getFileVersionHistory
result.append\(\(i\['timestamp'\], i\['user'\], u"%s×%s" % \(i\['width'\], i\['height'\]\), i\['size'\], i\['comment'\]\)\)
KeyError: 'comment'

There is no i\['comment'\] because the comment is hidden \(deleted\).

Result: The script crashes when running getFileVersionHistory. It would be better if getFileVersionHistory at least returns what's available, instead of returning nothing at all. For example, if you use i.get\('comment'\) instead of i\['comment'\], then getFileVersionHistory returns None if there is no comment. That seems much better than crashing.

Some version information:
Pywikipedia  \(r10715 \(wikipedia.py\), 2012/11/13, 20:56:05\)
Python 2.7.3 \(default, Aug  1 2012, 05:16:07\) 
\[GCC 4.6.3\]
config-settings:
use\_api = True
use\_api\_login = True
unicode test: ok
Comment 1 John Mark Vandenberg 2014-11-01 06:58:50 UTC
Need to determine if this problem exists on core.
Comment 2 Mpaa 2014-11-01 11:45:14 UTC
(In reply to John Mark Vandenberg from comment #1)
> Need to determine if this problem exists on core.

In core:
history = page.getFileVersionHistory() returns a list without crashing.

When trying to fetch the hidden comment, the result is:
>>> history[2]['comment']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 'comment


To note that history returns a "commenthidden" key in this case:
>>> history[2]['commenthidden']
u''

{
    "timestamp": "2007-02-14T13:01:57Z",
    "user": "Messina",
    "commenthidden": "",
    "url": "https://upload.wikimedia.org/wikipedia/commons/archive/3/3b/20110813064325%21Catania_Piazza_Quattro_Canti.jpg",
    "descriptionurl": "https://commons.wikimedia.org/wiki/File:Catania_Piazza_Quattro_Canti.jpg"
}

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


Navigation
Links