John Vandenberg has uploaded a new change for review.

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

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
(cherry picked from commit 5f4eabe94c651717b51927182951701237a54166)
---
M pywikibot/site.py
1 file changed, 3 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/06/243106/1

diff --git a/pywikibot/site.py b/pywikibot/site.py
index 5e3a53f..341b76f 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -4445,6 +4445,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.
 
@@ -4463,7 +4464,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

-- 
To view, visit https://gerrit.wikimedia.org/r/243106
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I280a4781f0f293e09dd94e14007f49cee30f60e3
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: John Vandenberg <[email protected]>
Gerrit-Reviewer: XZise <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to