Page MenuHomePhabricator

Resolve conflict between code and docs in BasePage.getDeletedRevision
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (needs admin rights, try on a wiki where you are admin):

import pywikibot
site = pywikibot.Site('wikipedia:hu')
page = pywikibot.Page(site, '2023')
print(type(page.getDeletedRevision('2023-01-30T19:11:36Z', content=True)))
print(page.getDeletedRevision('2023-01-30T19:11:36Z', content=True).keys())

What happens?:

<class 'dict'>
dict_keys(['revid', 'user', 'timestamp', 'slots', 'comment'])

What should have happened instead?:
https://doc.wikimedia.org/pywikibot/master/_modules/pywikibot/page/_basepage.html#BasePage.getDeletedRevision says:
return: a list of [date, editor, comment, text, restoration marker]. text will be None, unless content is True (or has been retrieved earlier).

This is a dictionary, no text (although available from slots), no marker, instead slots. Documentation and working code should be in accordance.

Software version (skip for WMF-hosted wikis like Wikipedia): 8.0.0

Details

Event Timeline

Xqt triaged this task as Low priority.
Xqt removed Xqt as the assignee of this task.Mar 31 2023, 11:04 AM
Xqt subscribed.

An empty list is given if no deleted revisions are found:

import pywikibot
site = pywikibot.Site('wikipedia:de')
page = pywikibot.Page(site, '2023')
site = pywikibot.Site('wikipedia:de', user='Xqt')
page = pywikibot.Page(site, '2023')
page.getDeletedRevision('2023-01-30T19:11:36Z')
[]

If an item is found, a dict is returned like

{'revid': 216107158, 'parentid': 216107091, 'user': '87.147.178.162', 'anon': '', 'timestamp': '2021-10-04T12:24:34Z', 'comment': 'SLA'}

The result is changed since the first Pywikibot core release (implemented by @russblau) but the documentation is from compat. I propose to change the documentation according to the result.

Change #1150499 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [doc] Fix documentation of Page.getDeletedRevision()

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

Xqt removed a project: TestMe.
Xqt moved this task from Backlog to Needs Review on the Pywikibot board.

Change #1150499 merged by jenkins-bot:

[pywikibot/core@master] [doc] Fix documentation of Page.getDeletedRevision()

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