Page MenuHomePhabricator

mw.wikibase.entityExists returns false for redirected entities
Closed, ResolvedPublic5 Story Points

Description

Problem
GIVEN Q123 is redirect entity
When I call mw.wikibase.entityExists('Q123')
Then I get false in return

Acceptance Criteria
GIVEN Q123 is redirect entity
When I call mw.wikibase.entityExists('Q123')
Then I must get true in return

Notes
Most ground work is done already as part of T112658: [Task] WikiPageEntityRevisionLookup::getLatestRevisionId() should throw an UnsersolvedRedirectException when encountering a redirect. .

Status: Investigated briefly and confirmed the problem still happens as of August 2019.

Event Timeline

hoo created this task.Apr 18 2018, 3:41 PM
Restricted Application added a project: Wikidata. · View Herald TranscriptApr 18 2018, 3:41 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

This should probably be handled more generally along the lines of T157868 and T127169. This is exactly why I felt it was better to implement a mw.wikibase.resolveEntityId that returns the resolved eid or nil if it does not exist rather than just the true or false of mw.wikibase.entityExists. If we had a mw.wikibase.resolveEntityId we could funnel all code through it that needed to check for existence and redirection instead of making every other function handle redirection, etc.

Currently I believe the only way to check for existence and redirection from Scribunto is via the heavy mw.wikibase.getEntity and we can soon check for existence with the new and undocumented mw.wikibase.entityExists, however, fixing it to handle redirection is not highly useful without being able to ascertain the redirection target or having all functions handle redirection. I personally prefer handling all redirection and existence via a single mw.wikibase.resolveEntityId type of function vs. having all the other functions that touch entities handling redirection. This forces coders to use the redirected target eids in all the other functions that do not handle redirection and existence vs. letting them continue to use old redirecting eids. The alternative is to have all functions handle redirection.

Change 433952 had a related patch set uploaded (by Eranroz; owner: Eranroz):
[mediawiki/extensions/Wikibase@master] getLatestRevisionId redirect handling

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

Change 453118 had a related patch set uploaded (by Aleksey Bekh-Ivanov (WMDE); owner: Aleksey Bekh-Ivanov (WMDE)):
[mediawiki/extensions/Wikibase@master] Introduce LatestRevisionIdResult

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

Change 453148 had a related patch set uploaded (by Aleksey Bekh-Ivanov (WMDE); owner: Aleksey Bekh-Ivanov (WMDE)):
[mediawiki/extensions/Wikibase@master] Use LatestRevisionIdResult in EntityRevisionLookup::getLatestRevisionId

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

Change 453118 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Introduce LatestRevisionIdResult

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

Change 453148 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Use LatestRevisionIdResult in EntityRevisionLookup::getLatestRevisionId

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

Is there anything left to do here or can it be closed?

Ahecht added a comment.Oct 4 2018, 3:51 PM

Is there anything left to do here or can it be closed?

What was the intended resolution? mw.wikibase.entityExists('Q404') still returns false.

alaa_wmde updated the task description. (Show Details)Jul 23 2019, 9:44 AM
alaa_wmde triaged this task as Normal priority.Jul 30 2019, 11:11 AM
alaa_wmde added a subscriber: alaa_wmde.

Let's check this and figure out what its status is.. it's been hanging around for a while and might be resolved already.

alaa_wmde updated the task description. (Show Details)Jul 30 2019, 11:11 AM

It still happens: (tested in beta cluster)

print(mw.wikibase.entityExists('Q478306'))
false
print(mw.wikibase.entityExists('Q478307'))
true

The look that is being passed to EntityAccessor is indeed RedirectResolvingEntityLookup but it can't understand redirects

ladsgroup@deployment-deploy01:~$ mwscript eval.php --wiki=enwiki
> $client = Wikibase\Client\WikibaseClient::getDefaultInstance()->getStore()->getEntityLookup();

> echo $client->hasEntity( new Wikibase\DataModel\Entity\ItemId( 'Q478306'));

> echo $client->hasEntity( new Wikibase\DataModel\Entity\ItemId( 'Q478307'));
1
> echo get_class( $client);
Wikibase\DataModel\Services\Lookup\RedirectResolvingEntityLookup

Broken in production as well:

ladsgroup@mwmaint1002:~$ mwscript eval.php --wiki=enwiki
> $client = Wikibase\Client\WikibaseClient::getDefaultInstance()->getStore()->getEntityLookup();

> echo $client->hasEntity( new Wikibase\DataModel\Entity\ItemId( 'Q400322'));

> echo $client->hasEntity( new Wikibase\DataModel\Entity\ItemId( 'Q17604838'));
1
>
eranroz removed eranroz as the assignee of this task.Jul 31 2019, 7:30 PM
eranroz added a subscriber: eranroz.

Removing myself as asignee (https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/Wikibase/+/453148/ by Aleksey was merged more than 0.5 year ago and my gerrit item https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/Wikibase/+/433952/ which use RevisionedUnresolvedRedirectException in WikiPageEntityRevisionLookup::getLatestRevisionId seems less relevant)

WMDE-leszek updated the task description. (Show Details)Aug 5 2019, 2:13 PM
WMDE-leszek updated the task description. (Show Details)
WMDE-leszek removed a project: Patch-For-Review.
darthmon_wmde set the point value for this task to 5.Aug 6 2019, 12:15 PM
Lydia_Pintscher raised the priority of this task from Normal to High.Aug 31 2019, 7:37 PM
Restricted Application added a project: User-Ladsgroup. · View Herald TranscriptSep 3 2019, 9:31 AM

So quick question from people who need this (ping @Uzume and @eranroz): Should mw.wikibase.entityExists('Q123') return true in case Q123 is redirect all the time or when it's redirecting to an existing entity?

Change 534394 had a related patch set uploaded (by Ladsgroup; owner: Ladsgroup):
[mediawiki/extensions/Wikibase@master] Make RevisionBasedEntityLookup throw redirect exception on redirects

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

Change 534394 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Make RevisionBasedEntityLookup throw redirect exception on redirects

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