jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] rollback: Use Revision instance properly ......................................................................
[FIX] rollback: Use Revision instance properly
The previous implementation assumed that the revisions are ordered by the id while they are in fact ordered by the timestamp. It also did iterate over the revision ids and not over the `Revision` instance which caused the loop to fail.
Now `APISite.rollbackpage` also requires the user to be logged in.
Change-Id: I280a4781f0f293e09dd94e14007f49cee30f60e3 --- M pywikibot/site.py 1 file changed, 3 insertions(+), 1 deletion(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py index 1da4bc5..68bb399 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -4702,6 +4702,7 @@ "alreadyrolled": "Page [[%(title)s]] already rolled back; action aborted.", } # other errors shouldn't arise because we check for those errors
+ @must_be('user') def rollbackpage(self, page, **kwargs): """Roll back page to version before last user's edits.
@@ -4720,7 +4721,8 @@ % page.title(asLink=True)) last_rev = page.latest_revision last_user = last_rev.user - for rev in sorted(list(page._revisions.keys()), reverse=True): + for rev in sorted(page._revisions.values(), reverse=True, + key=lambda r: r.timestamp): # start with most recent revision first if rev.user != last_user: break