XZise has uploaded a new change for review.

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

Change subject: [FIX] API: Don't set 'redirect' value if it couldn't be returned
......................................................................

[FIX] API: Don't set 'redirect' value if it couldn't be returned

All values, except 'redirect', were only modified in api.update_page, if
they were present. So if they weren't present because they weren't
requested, they were left untouched. But the 'redirect' property could
signal two states if it wasn't present: False or not requested. It treated
it as it was always requested so it stated the redirect status as false,
if not 'prop=info' was requested first.

This fix only updates 'redirect' if it has been requested which is
determined by the value for 'prop' used. If another value is added which
is only returned for a specific 'prop' value this can be used there too.
For anything else, where it's save to check if it is present and apply
changes a property of None does suffice.

Bug: 71104
Change-Id: I6224ca5c3de9ba78362681182f9dcc3b384af5ce
---
M pywikibot/data/api.py
M pywikibot/site.py
2 files changed, 8 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/57/162157/1

diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index b3ba2d9..1d1d232 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1195,14 +1195,17 @@
         pywikibot.cookie_jar.save()
 
 
-def update_page(page, pagedict):
+def update_page(page, pagedict, prop=None):
     """Update attributes of Page object page, based on query data in pagedict.
 
     @param page: object to be updated
     @type page: Page
     @param pagedict: the contents of a "page" element of a query response
     @type pagedict: dict
-
+    @param prop: the property name which resulted in pagedict. If None a
+        missing value does not indicate that it is 'False' but instead 'Not
+        determined'.
+    @type prop: str
     """
     if "pageid" in pagedict:
         page._pageid = int(pagedict['pageid'])
@@ -1211,7 +1214,8 @@
     else:
         raise AssertionError(
             "Page %s has neither 'pageid' nor 'missing' attribute" % 
pagedict['title'])
-    page._isredir = 'redirect' in pagedict
+    if prop == 'info':
+        page._isredir = 'redirect' in pagedict
     if 'touched' in pagedict:
         page._timestamp = pagedict['touched']
     if 'protection' in pagedict:
diff --git a/pywikibot/site.py b/pywikibot/site.py
index d4fe555..a94bd26 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -2129,7 +2129,7 @@
                     u"loadpageinfo: Query on %s returned data on '%s'"
                     % (page, pageitem['title']))
                 continue
-            api.update_page(page, pageitem)
+            api.update_page(page, pageitem, 'info')
 
     def loadcoordinfo(self, page):
         """Load [[mw:Extension:GeoData]] info."""

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6224ca5c3de9ba78362681182f9dcc3b384af5ce
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>

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

Reply via email to