Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Client\Usage\ImplicitDescriptionUsageLookup Class Reference

A UsageLookup which decorates an inner lookup and adds an implicit usage on a linked item’s description. More...

+ Inheritance diagram for Wikibase\Client\Usage\ImplicitDescriptionUsageLookup:
+ Collaboration diagram for Wikibase\Client\Usage\ImplicitDescriptionUsageLookup:

Public Member Functions

 __construct (UsageLookup $usageLookup, TitleFactory $titleFactory, bool $allowLocalShortDesc, DescriptionLookup $descriptionLookup, LinkBatchFactory $linkBatchFactory, string $globalSiteId, SiteLinkLookup $siteLinkLookup)
 
 getUsagesForPage (int $pageId)
 Get the entities used on the given page.
 
 getUnusedEntities (array $entityIds)
 Returns the elements of $entityIds that are currently not used as far as this UsageTracker knows.
 
- Public Member Functions inherited from Wikibase\Client\Usage\UsageLookup
 getPagesUsing (array $entityIds, array $aspects=[])
 Returns the pages that use any of the given entities.
 

Private Member Functions

 aspectsMatchImplicitUsage (array $aspects)
 Whether the given aspects potentially match an implicit usage.
 
 findImplicitUsages (array $entityIds)
 Find the implicit usages on the given entity IDs.
 
 filterImplicitUsages (array $itemIdsByPageId, array $contentLanguagesByPageId, array $aspects)
 Filter the implicit usages by the given aspects.
 

Private Attributes

 $usageLookup
 
 $titleFactory
 
 $allowLocalShortDesc
 
 $descriptionLookup
 
 $linkBatchFactory
 
 $globalSiteId
 
 $siteLinkLookup
 

Detailed Description

A UsageLookup which decorates an inner lookup and adds an implicit usage on a linked item’s description.

An implicit usage is different from an ordinary, explicit usage in that it is never recorded by a UsageTracker: it is not tracked when the page is parsed and actually uses a part of an entity, but rather synthesized by this class based on hard-coded knowledge about where else an entity’s data is used in relation to a page. However, implicit usages otherwise look exactly like explicit usages: for a user of the UsageLookup interface, it is not (yet?) possible to determine whether a usage from the lookup is explicit or implicit.

This class implements one kind of implicit usage: if a client page is linked to an item, it has an implicit usage on that item’s description in the client wiki’s content language, unless the client page also has a local description overriding the central one. This is because the description is used, for example, as part of the search result for the page (typically on mobile), even if it is never used in the page itself.

See also
Usage tracking for virtual usage, a similar but separate concept.

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Client\Usage\ImplicitDescriptionUsageLookup::__construct ( UsageLookup $usageLookup,
TitleFactory $titleFactory,
bool $allowLocalShortDesc,
DescriptionLookup $descriptionLookup,
LinkBatchFactory $linkBatchFactory,
string $globalSiteId,
SiteLinkLookup $siteLinkLookup )
Parameters
UsageLookup$usageLookupThe underlying/inner lookup.
TitleFactory$titleFactory
bool$allowLocalShortDescThe 'allowLocalShortDesc' client setting. If true, only pages with a local description will get an implicit usage.
DescriptionLookup$descriptionLookupUsed to look up local descriptions. Unused if $allowLocalShortDesc is false.
LinkBatchFactory$linkBatchFactory
string$globalSiteIdThe global site ID of the client wiki.
SiteLinkLookup$siteLinkLookup

Member Function Documentation

◆ aspectsMatchImplicitUsage()

Wikibase\Client\Usage\ImplicitDescriptionUsageLookup::aspectsMatchImplicitUsage ( array $aspects)
private

Whether the given aspects potentially match an implicit usage.

Parameters
string[]$aspects
Returns
bool

◆ filterImplicitUsages()

Wikibase\Client\Usage\ImplicitDescriptionUsageLookup::filterImplicitUsages ( array $itemIdsByPageId,
array $contentLanguagesByPageId,
array $aspects )
private

Filter the implicit usages by the given aspects.

Takes two arrays as returned by findImplicitUsages and returns similar arrays, but filtered if necessary.

Parameters
ItemId[]$itemIdsByPageId
string[]$contentLanguagesByPageId
string[]$aspects
Returns
array [ ItemId[] $itemIdsByPageId, string[] $contentLanguagesByPageId ]

◆ findImplicitUsages()

Wikibase\Client\Usage\ImplicitDescriptionUsageLookup::findImplicitUsages ( array $entityIds)
private

Find the implicit usages on the given entity IDs.

Returns two arrays, both keyed by page ID: the item ID linked to that page and the content language of the page.

Parameters
EntityId[]$entityIds
Returns
array [ ItemId[] $itemIdsByPageId, string[] $contentLanguagesByPageId ]

◆ getUnusedEntities()

Wikibase\Client\Usage\ImplicitDescriptionUsageLookup::getUnusedEntities ( array $entityIds)

Returns the elements of $entityIds that are currently not used as far as this UsageTracker knows.

In other words, this method answers the question which of a given list of entities are currently being used on wiki pages.

Parameters
EntityId[]$entityIds
Returns
EntityId[] A list of elements of $entityIds that are unused.

Implements Wikibase\Client\Usage\UsageLookup.

◆ getUsagesForPage()

Wikibase\Client\Usage\ImplicitDescriptionUsageLookup::getUsagesForPage ( int $pageId)

Get the entities used on the given page.

The returned array uses the identity string as the key, so that a specific usage can be found quickly.

Parameters
int$pageId
Returns
EntityUsage[] keyed by identity string

Implements Wikibase\Client\Usage\UsageLookup.

Member Data Documentation

◆ $allowLocalShortDesc

Wikibase\Client\Usage\ImplicitDescriptionUsageLookup::$allowLocalShortDesc
private

◆ $descriptionLookup

Wikibase\Client\Usage\ImplicitDescriptionUsageLookup::$descriptionLookup
private

◆ $globalSiteId

Wikibase\Client\Usage\ImplicitDescriptionUsageLookup::$globalSiteId
private

◆ $linkBatchFactory

Wikibase\Client\Usage\ImplicitDescriptionUsageLookup::$linkBatchFactory
private

◆ $siteLinkLookup

Wikibase\Client\Usage\ImplicitDescriptionUsageLookup::$siteLinkLookup
private

◆ $titleFactory

Wikibase\Client\Usage\ImplicitDescriptionUsageLookup::$titleFactory
private

◆ $usageLookup

Wikibase\Client\Usage\ImplicitDescriptionUsageLookup::$usageLookup
private

The documentation for this class was generated from the following file: