Page MenuHomePhabricator

logentries.LogEntryFactory creates invalid LogEntry type
Closed, ResolvedPublic


logentries.LogEntryFactory creates invalid LogEntry type instead of raising an error:

>>> import pwb, pywikibot as py
>>> from pywikibot.logentries import LogEntry
>>> site = py.Site()
>>> lef = LogEntryFactory(site)
>>> data = {'type': 'foo'}
>>> x = lef._createFromData(data)
>>> type(x)
<class 'pywikibot.logentries.LogEntry'>
>>> x.type()
>>> x._expectedType is None

There is an exception handling inside _createFromData() method but the KeyError will never raised because _getEntryClass takes it and always returns a generic LogEntry object.

Event Timeline

Xqt triaged this task as Medium priority.May 17 2016, 1:51 PM

Change 289227 had a related patch set uploaded (by Xqt):
[bugfix] LogEntry is not a valid logtype class

MediaWiki has lots of log types that we dont have specialised classes for, and new log types are created regularly. We must have a fallback class which holds the basic log entry data . Currently it is LogEntry, but it could be a special subclass like UnrecognisedLogEntry .

Change 289227 merged by jenkins-bot:
[pywikibot/core@master] [IMPR] Show a warning when a LogEntry type is not known