MediaWiki master
MediaWiki\Page\LinkBatchFactory Class Reference

Factory for LinkBatch objects to batch query page metadata. More...

Public Member Functions

 __construct (private LinkCache $linkCache, private TitleFormatter $titleFormatter, private Language $contentLanguage, private GenderCache $genderCache, private IConnectionProvider $dbProvider, private LinksMigration $linksMigration, private TempUserDetailsLookup $tempUserDetailsLookup, private LinkAlwaysKnownLookup $linkAlwaysKnownLookup, private LoggerInterface $logger)
 
 newLinkBatch (iterable $titles=[])
 
 preloadPersistentCache (array $pages, string $fname)
 Warm-up titles that qualify for the persistent version of LinkCache.
 

Detailed Description

Factory for LinkBatch objects to batch query page metadata.

Use via MediaWikiServices::getLinkBatchFactory()->newLinkBatch(), and then call LinkBatch::execute().

See also
docs/LinkCache.md
MediaWiki\Page\LinkCache
Since
1.35

Definition at line 29 of file LinkBatchFactory.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Page\LinkBatchFactory::__construct ( private LinkCache $linkCache,
private TitleFormatter $titleFormatter,
private Language $contentLanguage,
private GenderCache $genderCache,
private IConnectionProvider $dbProvider,
private LinksMigration $linksMigration,
private TempUserDetailsLookup $tempUserDetailsLookup,
private LinkAlwaysKnownLookup $linkAlwaysKnownLookup,
private LoggerInterface $logger )

Definition at line 31 of file LinkBatchFactory.php.

Member Function Documentation

◆ newLinkBatch()

MediaWiki\Page\LinkBatchFactory::newLinkBatch ( iterable $titles = [])
Parameters
iterable<LinkTarget>|iterable<PageReference>$titles Initial titles for this batch
Returns
LinkBatch

Definition at line 48 of file LinkBatchFactory.php.

◆ preloadPersistentCache()

MediaWiki\Page\LinkBatchFactory::preloadPersistentCache ( array $pages,
string $fname )

Warm-up titles that qualify for the persistent version of LinkCache.

If your use case involves a set of titles that:

  • qualify for the persistent cache (see LinkCache::usePersistentCache and the architecture doc at docs/LinkCache.md),
  • and are constant between requests (likely all together a cache-hit),
  • and that you know upfront (i.e. can batch)
  • and that eliminate the need for a database query if they are all a hit

Then consider using this method instead of ::newLinkBatch.

This method tries WANObjectCache first and falls back to backfilling from a database query using ::newLinkBatch. It then warms up the in-process LinkCache with the results.

Designed for use by ResourceLoader\WikiModule::preloadTitleInfo (T393835).

Since
1.47
Parameters
string[]$pages

Definition at line 84 of file LinkBatchFactory.php.


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