MediaWiki  master
LinkBatch Class Reference

Class representing a list of titles The execute() method checks them all for existence and adds them to a LinkCache object. More...

Collaboration diagram for LinkBatch:

Public Member Functions

 __construct (iterable $arr=[], ?LinkCache $linkCache=null, ?TitleFormatter $titleFormatter=null, ?Language $contentLanguage=null, ?GenderCache $genderCache=null, ?ILoadBalancer $loadBalancer=null, ?LinksMigration $linksMigration=null, ?LoggerInterface $logger=null)
 
 add ( $ns, $dbkey)
 
 addObj ( $link)
 
 addResultToCache ( $cache, $res)
 Add a result wrapper containing IDs and titles to a LinkCache object. More...
 
 constructSet ( $prefix, $db)
 Construct a WHERE clause which will match all the given titles. More...
 
 doGenderQuery ()
 Do (and cache) {{GENDER:...}} information for userpages in this LinkBatch. More...
 
 doQuery ()
 Perform the existence test query, return a result wrapper with page_id fields. More...
 
 execute ()
 Do the query and add the results to the LinkCache object. More...
 
 getPageIdentities ()
 Do the query, add the results to the LinkCache object, and return ProperPageIdentity instances corresponding to the pages in the batch. More...
 
 getSize ()
 Returns the size of the batch. More...
 
 isEmpty ()
 Returns true if no pages have been added, false otherwise. More...
 
 setArray ( $array)
 Set the link list to a given 2-d array First key is the namespace, second is the DB key, value arbitrary. More...
 
 setCaller ( $caller)
 Use ->setCaller( METHOD ) to indicate which code is using this class. More...
 

Public Attributes

array[] $data = []
 2-d array, first index namespace, second index dbkey, value arbitrary More...
 

Protected Member Functions

 executeInto ( $cache)
 Do the query and add the results to a given LinkCache object Return an array mapping PDBK to ID. More...
 

Protected Attributes

string null $caller
 For debugging which method is using this class. More...
 

Private Attributes

Language $contentLanguage
 
GenderCache $genderCache
 
LinkCache $linkCache
 
LinksMigration $linksMigration
 
ILoadBalancer $loadBalancer
 
LoggerInterface $logger
 
ProperPageIdentity[] null $pageIdentities = null
 page identity objects corresponding to the links in the batch More...
 
TitleFormatter $titleFormatter
 

Detailed Description

Class representing a list of titles The execute() method checks them all for existence and adds them to a LinkCache object.

Definition at line 44 of file LinkBatch.php.

Constructor & Destructor Documentation

◆ __construct()

LinkBatch::__construct ( iterable  $arr = [],
?LinkCache  $linkCache = null,
?TitleFormatter  $titleFormatter = null,
?Language  $contentLanguage = null,
?GenderCache  $genderCache = null,
?ILoadBalancer  $loadBalancer = null,
?LinksMigration  $linksMigration = null,
?LoggerInterface  $logger = null 
)
Parameters
iterable<LinkTarget>|iterable<PageReference>$arr Initial items to be added to the batch
LinkCache | null$linkCache
TitleFormatter | null$titleFormatter
Language | null$contentLanguage
GenderCache | null$genderCache
ILoadBalancer | null$loadBalancer
LinksMigration | null$linksMigration
LoggerInterface | null$logger
Deprecated:
since 1.35 Use makeLinkBatch of the LinkBatchFactory service instead

Definition at line 102 of file LinkBatch.php.

References $contentLanguage, $genderCache, $linkCache, $linksMigration, $loadBalancer, $logger, $titleFormatter, and addObj().

Member Function Documentation

◆ add()

LinkBatch::add (   $ns,
  $dbkey 
)
Parameters
int$ns
string$dbkey

Definition at line 173 of file LinkBatch.php.

Referenced by addObj().

◆ addObj()

LinkBatch::addObj (   $link)
Parameters
LinkTarget | PageReference$link

Definition at line 147 of file LinkBatch.php.

References add(), and MediaWiki\Linker\LinkTarget\isExternal().

Referenced by __construct().

◆ addResultToCache()

LinkBatch::addResultToCache (   $cache,
  $res 
)

Add a result wrapper containing IDs and titles to a LinkCache object.

As normal, titles will go into the static Title cache field. This function also stores extra fields of the title used for link parsing to avoid extra DB queries.

Parameters
LinkCache$cache
IResultWrapper$res
Returns
int[] Array of remaining titles

Definition at line 260 of file LinkBatch.php.

References $cache, $res, and $title.

◆ constructSet()

LinkBatch::constructSet (   $prefix,
  $db 
)

Construct a WHERE clause which will match all the given titles.

Parameters
string$prefixThe appropriate table's field name prefix ('page', 'pl', etc)
IDatabase$dbDB object to use
Returns
string|bool String with SQL where clause fragment, or false if no items.

Definition at line 379 of file LinkBatch.php.

◆ doGenderQuery()

LinkBatch::doGenderQuery ( )

Do (and cache) {{GENDER:...}} information for userpages in this LinkBatch.

Returns
bool Whether the query was successful

Definition at line 358 of file LinkBatch.php.

◆ doQuery()

LinkBatch::doQuery ( )

Perform the existence test query, return a result wrapper with page_id fields.

Returns
bool|IResultWrapper

Definition at line 329 of file LinkBatch.php.

References $dbr, DB_REPLICA, and LinkCache\getSelectFields().

◆ execute()

LinkBatch::execute ( )

Do the query and add the results to the LinkCache object.

Returns
int[] Mapping PDBK to ID

Definition at line 218 of file LinkBatch.php.

References executeInto().

Referenced by getPageIdentities().

◆ executeInto()

LinkBatch::executeInto (   $cache)
protected

Do the query and add the results to a given LinkCache object Return an array mapping PDBK to ID.

Parameters
LinkCache$cache
Returns
int[] Remaining IDs

Definition at line 244 of file LinkBatch.php.

References $cache, and $res.

Referenced by execute().

◆ getPageIdentities()

LinkBatch::getPageIdentities ( )

Do the query, add the results to the LinkCache object, and return ProperPageIdentity instances corresponding to the pages in the batch.

Since
1.37
Returns
ProperPageIdentity[] A list of ProperPageIdentities

Definition at line 229 of file LinkBatch.php.

References execute().

◆ getSize()

LinkBatch::getSize ( )

Returns the size of the batch.

Returns
int

Definition at line 209 of file LinkBatch.php.

Referenced by isEmpty().

◆ isEmpty()

LinkBatch::isEmpty ( )

Returns true if no pages have been added, false otherwise.

Returns
bool

Definition at line 200 of file LinkBatch.php.

References getSize().

◆ setArray()

LinkBatch::setArray (   $array)

Set the link list to a given 2-d array First key is the namespace, second is the DB key, value arbitrary.

Parameters
array$array

Definition at line 191 of file LinkBatch.php.

◆ setCaller()

LinkBatch::setCaller (   $caller)

Use ->setCaller( METHOD ) to indicate which code is using this class.

Only used in debugging output.

Since
1.17
Parameters
string$caller
Returns
self (since 1.32)

Definition at line 138 of file LinkBatch.php.

References $caller.

Member Data Documentation

◆ $caller

string null LinkBatch::$caller
protected

For debugging which method is using this class.

Definition at line 58 of file LinkBatch.php.

Referenced by setCaller().

◆ $contentLanguage

Language LinkBatch::$contentLanguage
private

Definition at line 73 of file LinkBatch.php.

Referenced by __construct().

◆ $data

array [] LinkBatch::$data = []

2-d array, first index namespace, second index dbkey, value arbitrary

Definition at line 48 of file LinkBatch.php.

◆ $genderCache

GenderCache LinkBatch::$genderCache
private

Definition at line 78 of file LinkBatch.php.

Referenced by __construct().

◆ $linkCache

LinkCache LinkBatch::$linkCache
private

Definition at line 63 of file LinkBatch.php.

Referenced by __construct().

◆ $linksMigration

LinksMigration LinkBatch::$linksMigration
private

Definition at line 86 of file LinkBatch.php.

Referenced by __construct().

◆ $loadBalancer

ILoadBalancer LinkBatch::$loadBalancer
private

Definition at line 83 of file LinkBatch.php.

Referenced by __construct().

◆ $logger

LoggerInterface LinkBatch::$logger
private

Definition at line 89 of file LinkBatch.php.

Referenced by __construct().

◆ $pageIdentities

ProperPageIdentity [] null LinkBatch::$pageIdentities = null
private

page identity objects corresponding to the links in the batch

Definition at line 53 of file LinkBatch.php.

◆ $titleFormatter

TitleFormatter LinkBatch::$titleFormatter
private

Definition at line 68 of file LinkBatch.php.

Referenced by __construct().


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