Page MenuHomePhabricator

User class for autoblock ID is broken
Closed, ResolvedPublic

Description

The User class is a subclass of Page offering special methods relevant to a MediaWiki user as well as the page for the User.

It also has functionality to represent an autoblock ID, likely solely because T19781: list=logevents shows "User:#<blockid>" as a title for autoblock unblock entries. The log entry API returns titles of 'User:#<autoblockid>' for English sites and 'Benutzer:#<autoblockid>' for German sites.

As User:#<autoblockid> is an invalid MediaWiki page title, the User class detects a 'page' title of '#<autoblockid>' , removes the # and so creates a User with title 'User:<auoblockid>'.

While User(site, '#<autoblockid>')works, it does not support User(site, 'User:#<autoblockid>') or User(site, 'Benutzer:#<autoblockid>'). Including a namespace results in an exception:

  File "pywikibot/page.py", line 2718, in __init__
    if self.namespace() != 2:
  File "pywikibot/page.py", line 173, in namespace
    return self._link.namespace
  File "pywikibot/page.py", line 4896, in namespace
    self.parse()
  File "pywikibot/page.py", line 4824, in parse
    u"'{0}' has no title.".format(self._text))
InvalidTitle: 'User:#1338201' has no title.

An autoblock ID is also nothing like a MediaWiki user. The only user feature that can be used with an autoblockid is unblock (even reblock is not possible). However the User class does not offer an unblock method, so every method of User and inherited Page is invalid for an autoblock ID. The only method that understands that '#' was stripped from the 'title' is User.username. Several other User methods raise exception AutoblockUser when used with an autoblock ID. However not all User methods do this, and inherited methods do not. In the case of inherited User.title(), it will return the incorrect title - the title of a different MediaWiki user.

Event Timeline

jayvdb claimed this task.
jayvdb raised the priority of this task from to High.
jayvdb updated the task description. (Show Details)
jayvdb added a project: Pywikibot.
jayvdb subscribed.

Change 230405 had a related patch set uploaded (by John Vandenberg):
Special User subclass for autoblock IDs

https://gerrit.wikimedia.org/r/230405

Change 362797 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [bugfix] Don't fail when creating User class for autobloc id

https://gerrit.wikimedia.org/r/362797

Change 362797 merged by jenkins-bot:
[pywikibot/core@master] [bugfix] Don't fail when creating User class for autoblock id

https://gerrit.wikimedia.org/r/362797

(probable error)

Coud you explain?

Xqt raised the priority of this task from High to Needs Triage.Feb 3 2019, 11:36 AM
Xqt moved this task from Needs Review to Backlog on the Pywikibot board.

Sorry, it seems I was mistaken. So I'm closing again.