Page MenuHomePhabricator

page.isRedirectPage() reports always False after page.isDisambig()
Closed, ResolvedPublic

Description

When calling page.isDisambig() a page.isRedirectPage() followed after that is reporting it always false. Calling 'page.text' does 'fix' that so that it returns the actual value.

import pywikibot
enwp = pywikibot.Site('en', 'wikipedia')
page = pywikibot.Page(enwp, 'TBBT')
page.isRedirectPage()

True

page = pywikibot.Page(enwp, 'TBBT')
not page.isDisambig()

True

page.isRedirectPage()

False

page.text

'#REDIRECT [[The Big Bang Theory]]'

page.isRedirectPage()

True


Version: core-(2.0)
Severity: normal

Details

Reference
bz71104

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 3:43 AM
bzimport set Reference to bz71104.
bzimport added a subscriber: Unknown Object (????).

Okay the reason is the following: Page.isDisambig() calls site.loadpageprops() which loads them and calls data.api.update_page() and this isn't differentiating between prop=pageprops and prop=info, and 'pageprops' is no redirect info.

I'd like to know if there is a reason when to use prop=pageprops? It looks to me all the data is also in prop=info.

Another fix would be, to only update those properties which have been received, because the property is not present if it's False so it needs to know if that property is not present because it's False or because it wasn't requested.

gerritadmin wrote:

Change 162157 had a related patch set uploaded by XZise:
[FIX] API: Don't set 'redirect' value if it couldn't be returned

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

Okay 'prop=pageprops' doesn't work how I thought it worked. And because there are other cases in which update_page was called, I made a more general fix: 'update_page' now receives the property with which the pagedict was obtained. If any value in the result is only present for a specific property and a missing value could indicate that it's False or not requested, this does allow an easy check to determine between both possibilites.

gerritadmin wrote:

Change 162157 merged by jenkins-bot:
[FIX] API: Don't set 'redirect' value if it couldn't be returned

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