jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/336886 )
Change subject: Update internals after redirecting items ......................................................................
Update internals after redirecting items
Change-Id: I9c458363b976e987a0e9b60e192b84e51b4999ea --- M pywikibot/page.py 1 file changed, 7 insertions(+), 2 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py index e44f393..a091956 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -4466,6 +4466,7 @@ item.latest_revision_id = data['to']['lastrevid'] if data.get('redirected', 0): self._isredir = True + self._redirtarget = item
def set_redirect_target(self, target_page, create=False, force=False, keep_section=False, save=True, **kwargs): @@ -4475,7 +4476,7 @@ You need to define an extra argument to make this work, like save=True
@param target_page: target of the redirect, this argument is required. - @type target_page: pywikibot.Item or string + @type target_page: ItemPage or string @param force: if true, it sets the redirect target even the page is not redirect. @type force: bool @@ -4488,8 +4489,12 @@ raise pywikibot.IsNotRedirectPage(self) if not save or keep_section or create: raise NotImplementedError - self.repo.set_redirect_target( + data = self.repo.set_redirect_target( from_item=self, to_item=target_page) + if data.get('success', 0): + del self.latest_revision_id + self._isredir = True + self._redirtarget = target_page
def isRedirectPage(self): """Return True if item is a redirect, False if not or not existing."""
pywikibot-commits@lists.wikimedia.org