jenkins-bot has submitted this change and it was merged.

Change subject: [FIX] Logentries: Use the query's site argument
......................................................................


[FIX] Logentries: Use the query's site argument

The 'title' and 'new_title' methods of LogEntry and MoveEntry both don't
use the site used to generate the log entries but the default site
object.

This is a breaking change as LogEntry and LogEntryFactory now require a
site parameter.

Bug: T75723
Change-Id: Ia965ce5c4733f9fef84d58f556dd4b1f5d46fc8b
---
M pywikibot/data/api.py
M pywikibot/logentries.py
2 files changed, 12 insertions(+), 8 deletions(-)

Approvals:
  John Vandenberg: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 8aa97b4..0400f5d 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1689,7 +1689,7 @@
         ListGenerator.__init__(self, "logevents", **kwargs)
 
         from pywikibot import logentries
-        self.entryFactory = logentries.LogEntryFactory(logtype)
+        self.entryFactory = logentries.LogEntryFactory(self.site, logtype)
 
     def result(self, pagedata):
         return self.entryFactory.create(pagedata)
diff --git a/pywikibot/logentries.py b/pywikibot/logentries.py
index 5a71ad9..5b35cd8 100644
--- a/pywikibot/logentries.py
+++ b/pywikibot/logentries.py
@@ -37,9 +37,10 @@
     # Overriden in subclasses.
     _expectedType = None
 
-    def __init__(self, apidata):
+    def __init__(self, apidata, site):
         """Initialize object from a logevent dict returned by MW API."""
         self.data = LogDict(apidata)
+        self.site = site
         if self._expectedType is not None and self._expectedType != 
self.type():
             raise Error("Wrong log type! Expecting %s, received %s instead."
                         % (self._expectedType, self.type()))
@@ -59,7 +60,7 @@
     def title(self):
         """Page on which action was performed."""
         if not hasattr(self, '_title'):
-            self._title = pywikibot.Page(pywikibot.Link(self.data['title']))
+            self._title = pywikibot.Page(self.site, self.data['title'])
         return self._title
 
     def type(self):
@@ -88,9 +89,9 @@
 
     _expectedType = 'block'
 
-    def __init__(self, apidata):
+    def __init__(self, apidata, site):
         """Constructor."""
-        super(BlockEntry, self).__init__(apidata)
+        super(BlockEntry, self).__init__(apidata, site)
         # see 
en.wikipedia.org/w/api.php?action=query&list=logevents&letype=block&lelimit=1&lestart=2009-03-04T00:35:07Z
         # When an autoblock is removed, the "title" field is not a page title
         # ( https://bugzilla.wikimedia.org/show_bug.cgi?id=17781 )
@@ -205,7 +206,7 @@
     def new_title(self):
         """Return page object of the new title."""
         if not hasattr(self, '_new_title'):
-            self._new_title = 
pywikibot.Page(pywikibot.Link(self.data['move']['new_title']))
+            self._new_title = pywikibot.Page(self.site, 
self.data['move']['new_title'])
         return self._new_title
 
     def suppressedredirect(self):
@@ -261,15 +262,18 @@
         'newusers': NewUsersEntry
     }
 
-    def __init__(self, logtype=None):
+    def __init__(self, site, logtype=None):
         """
         Constructor.
 
+        @param site: The site on which the log entries are created.
+        @type site: BaseSite
         @param logtype: The log type of the log entries, if known in advance.
                         If None, the Factory will fetch the log entry from
                         the data to create each object.
         @type logtype: (letype) str : move/block/patrol/etc...
         """
+        self._site = site
         if logtype is None:
             self._creator = self._createFromData
         else:
@@ -286,7 +290,7 @@
 
         @return: LogEntry object representing logdata
         """
-        return self._creator(logdata)
+        return self._creator(logdata, self._site)
 
     @staticmethod
     def _getEntryClass(logtype):

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia965ce5c4733f9fef84d58f556dd4b1f5d46fc8b
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: Zhuyifei1999 <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to