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

Change subject: If we already have pageproperties, use it for ItemPage.fromPage
......................................................................


If we already have pageproperties, use it for ItemPage.fromPage

The Wikibase Id is stored in the pageproperties, so lets use
it if we can.

Change-Id: I1a4a7d4235bd4e3717f0e6248ab90f10460f264b
---
M pywikibot/page.py
1 file changed, 6 insertions(+), 0 deletions(-)

Approvals:
  Merlijn van Deen: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/page.py b/pywikibot/page.py
index 4147b4f..07fe099 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -2526,8 +2526,14 @@
     def fromPage(cls, page):
         """
         Get the ItemPage based on a Page that links to it
+        @param page: Page
+        @return: ItemPage
         """
         repo = page.site.data_repository()
+        if hasattr(page, '_pageprops') and 
page.properties().get('wikibase_item'):
+            # If we have already fetched the pageprops for something else,
+            # we already have the id, so use it
+            return cls(repo, page.properties().get('wikibase_item'))
         i = cls(repo, 'null')
         del i.id
         i._site = page.site

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1a4a7d4235bd4e3717f0e6248ab90f10460f264b
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhall...@arctus.nl>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to