MediaWiki REL1_32
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...

Public Member Functions

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

Public Attributes

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

Protected Member Functions

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

Protected Attributes

 $caller
 For debugging which method is using this class.
 

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 34 of file LinkBatch.php.

Constructor & Destructor Documentation

◆ __construct()

LinkBatch::__construct (   $arr = [])
Parameters
Traversable | LinkTarget[]$arrInitial items to be added to the batch

Definition at line 48 of file LinkBatch.php.

References addObj(), and as.

Member Function Documentation

◆ add()

◆ addObj()

LinkBatch::addObj (   $linkTarget)
Parameters
LinkTarget$linkTarget

Definition at line 71 of file LinkBatch.php.

References add(), and wfDebug().

Referenced by __construct(), TemplatesOnThisPageFormatter\format(), and CategoryPager\getBody().

◆ addResultToCache()

LinkBatch::addResultToCache (   $cache,
  $res 
)

Add a ResultWrapper 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
ResultWrapper$res
Returns
array Array of remaining titles

Definition at line 158 of file LinkBatch.php.

References $cache, $data, $res, $title, and as.

Referenced by executeInto().

◆ 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 246 of file LinkBatch.php.

References data.

Referenced by doQuery().

◆ doGenderQuery()

LinkBatch::doGenderQuery ( )

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

Returns
bool Whether the query was successful

Definition at line 223 of file LinkBatch.php.

References $services, data, and isEmpty().

Referenced by executeInto().

◆ doQuery()

LinkBatch::doQuery ( )

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

Returns
bool|ResultWrapper

Definition at line 193 of file LinkBatch.php.

References $caller, $dbr, $res, constructSet(), DB_REPLICA, isEmpty(), and wfGetDB().

Referenced by executeInto().

◆ execute()

LinkBatch::execute ( )

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

Returns
array Mapping PDBK to ID

Definition at line 127 of file LinkBatch.php.

References executeInto().

◆ 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
array Remaining IDs

Definition at line 140 of file LinkBatch.php.

References $cache, $res, addResultToCache(), doGenderQuery(), and doQuery().

Referenced by execute().

◆ getSize()

LinkBatch::getSize ( )

Returns the size of the batch.

Returns
int

Definition at line 118 of file LinkBatch.php.

References data.

Referenced by isEmpty().

◆ isEmpty()

LinkBatch::isEmpty ( )

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

Returns
bool

Definition at line 109 of file LinkBatch.php.

References getSize().

Referenced by doGenderQuery(), and doQuery().

◆ 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 100 of file LinkBatch.php.

References data.

Referenced by OutputPage\addCategoryLinksToLBAndGetResult(), and ApiParse\formatCategoryLinks().

◆ 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 62 of file LinkBatch.php.

References $caller.

Referenced by BlockListPager\preprocessResults().

Member Data Documentation

◆ $caller

LinkBatch::$caller
protected

For debugging which method is using this class.

Definition at line 43 of file LinkBatch.php.

Referenced by doQuery(), and setCaller().

◆ $data

LinkBatch::$data = []

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

Definition at line 38 of file LinkBatch.php.

Referenced by addResultToCache().


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