Page MenuHomePhabricator

Add method to delete specific versions of files
Closed, ResolvedPublicFeature

Description

If a file has multiple revisions, sysops can delete any of the older versions. On the web version, this translates to action=delete with oldimage parameter being provided; something like https://test.wikipedia.org/w/index.php?title=File:Bottest.png&action=delete&oldimage=20210106143243%21Bottest.png

MW API allows this through API:Delete as well; similar to above, action should be set to delete and oldimage should be provided.

Pywikibot currently does not support it. While _apisite.py has a deletepage() method, that can only be used to delete a page as a whole. We should add support for this in pywikibot.

Event Timeline

Xqt triaged this task as Medium priority.Mar 7 2021, 10:23 PM
Xqt changed the subtype of this task from "Task" to "Feature Request".

@Xqt I think I got this figure out in https://gerrit.wikimedia.org/r/c/pywikibot/core/+/669584

The unit test has one hacky part where in order to identify the fileid of the deleted revision so I can undelete it, I call the site.filearchive() method and I pass the name of the testwiki file used by the unit test (which is https://test.wikipedia.org/wiki/File:T276725.png by the way). In order to limit the number of results returned, I need to pass an end name too, but filearchvie() does not allow you to pass the same name for both start and end so I added another "g" to the end of "png" to ensure that only entries about this file are returned. If you can think of a better way please let me know. Note that the fileid value changes every time the version is deleted by the previous lines of the unit test so unlike the timestamp, we cannot hard code it into the unit test.

Change 669584 had a related patch set uploaded (by Huji; owner: Huji):
[pywikibot/core@master] Support deleting and undeleting specific file versions

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

By the way, where do we run the unit tests? Evidently, it is not test.wikipedia.org anymore. Is it in a dockerized installation of MediaWiki? Some other wiki? Do we not run them at all?

Change 671364 had a related patch set uploaded (by Huji; owner: Huji):
[pywikibot/core@master] Support deleting and undeleting specific file versions

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

Change 671365 had a related patch set uploaded (by Huji; owner: Huji):
[pywikibot/core@master] Support deleting and undeleting specific file versions

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

Change 671366 had a related patch set uploaded (by Huji; owner: Huji):
[pywikibot/core@master] Support deleting and undeleting specific file versions

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

Change 671366 abandoned by Huji:
[pywikibot/core@master] Support deleting and undeleting specific file versions

Reason:

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

Change 671365 abandoned by Huji:
[pywikibot/core@master] Support deleting and undeleting specific file versions

Reason:

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

Change 669584 abandoned by Huji:
[pywikibot/core@master] Support deleting and undeleting specific file versions

Reason:
In favor of If0d0944bd0f775d6e0fc8d5970db2fbee2ab1704

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

By the way, where do we run the unit tests? Evidently, it is not test.wikipedia.org anymore. Is it in a dockerized installation of MediaWiki? Some other wiki? Do we not run them at all?

We do not run tests with 'write'attribute (but I don't know the reason for this)

Change 671364 merged by jenkins-bot:
[pywikibot/core@master] Support deleting and undeleting specific file versions

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