MediaWiki
master
|
Class for fetching backlink lists, approximate backlink counts and partitions. More...
Public Member Functions | |
__construct (ServiceOptions $options, LinksMigration $linksMigration, WANObjectCache $wanCache, HookContainer $hookContainer, IConnectionProvider $dbProvider, PageReference $page) | |
Create a new BacklinkCache. More... | |
getCascadeProtectedLinkPages () | |
Get a PageIdentity iterator for cascade-protected template/file use backlinks. More... | |
getLinkPages (string $table, $startId=false, $endId=false, $max=INF) | |
Get the backlinks for a given table. More... | |
getNumLinks ( $table, $max=INF) | |
Get the approximate number of backlinks. More... | |
getPage () | |
hasLinks ( $table) | |
Check if there are any backlinks. More... | |
partition ( $table, $batchSize) | |
Partition the backlinks into batches. More... | |
Public Attributes | |
const | CONSTRUCTOR_OPTIONS |
Protected Member Functions | |
getDB () | |
Get the replica DB connection to the database. More... | |
getPrefix ( $table) | |
Get the field name prefix for a given table. More... | |
partitionResult ( $res, $batchSize, $isComplete=true) | |
Partition a DB result with backlinks in it into batches. More... | |
queryLinks ( $table, $startId, $endId, $max, $select='all') | |
Get the backlinks for a given table. More... | |
Protected Attributes | |
IResultWrapper[] | $fullResultCache = [] |
Contains the whole links from a database result. More... | |
PageReference | $page |
Local copy of a PageReference object. More... | |
array[] | $partitionCache = [] |
Multi dimensions array representing batches. More... | |
WANObjectCache | $wanCache |
Class for fetching backlink lists, approximate backlink counts and partitions.
This is a shared cache.
Instances of this class should typically be fetched with the method ::getBacklinkCache() from the BacklinkCacheFactory service.
Ideally you should only get your backlinks from here when you think there is some advantage in caching them. Otherwise, it's just a waste of memory.
Introduced by r47317
Definition at line 58 of file BacklinkCache.php.
BacklinkCache::__construct | ( | ServiceOptions | $options, |
LinksMigration | $linksMigration, | ||
WANObjectCache | $wanCache, | ||
HookContainer | $hookContainer, | ||
IConnectionProvider | $dbProvider, | ||
PageReference | $page | ||
) |
Create a new BacklinkCache.
ServiceOptions | $options | |
LinksMigration | $linksMigration | |
WANObjectCache | $wanCache | |
HookContainer | $hookContainer | |
IConnectionProvider | $dbProvider | |
PageReference | $page | Page to create a backlink cache for |
Definition at line 115 of file BacklinkCache.php.
References $page, $wanCache, and MediaWiki\Config\ServiceOptions\assertRequiredOptions().
BacklinkCache::getCascadeProtectedLinkPages | ( | ) |
Get a PageIdentity iterator for cascade-protected template/file use backlinks.
Definition at line 500 of file BacklinkCache.php.
|
protected |
Get the replica DB connection to the database.
Definition at line 145 of file BacklinkCache.php.
BacklinkCache::getLinkPages | ( | string | $table, |
$startId = false , |
|||
$endId = false , |
|||
$max = INF |
|||
) |
Get the backlinks for a given table.
Cached in process memory only.
string | $table | |
int | bool | $startId | |
int | bool | $endId | |
int | float | $max | Integer, or INF for no max |
Definition at line 158 of file BacklinkCache.php.
BacklinkCache::getNumLinks | ( | $table, | |
$max = INF |
|||
) |
Get the approximate number of backlinks.
string | $table | |
int | float | $max | Only count up to this many backlinks, or INF for no max |
Definition at line 342 of file BacklinkCache.php.
References getDB().
BacklinkCache::getPage | ( | ) |
|
protected |
Get the field name prefix for a given table.
string | $table |
Definition at line 221 of file BacklinkCache.php.
BacklinkCache::hasLinks | ( | $table | ) |
Check if there are any backlinks.
string | $table |
Definition at line 332 of file BacklinkCache.php.
BacklinkCache::partition | ( | $table, | |
$batchSize | |||
) |
Partition the backlinks into batches.
Returns an array giving the start and end of each range. The first batch has a start of false, and the last batch has an end of false.
string | $table | The links table name |
int | $batchSize |
Definition at line 394 of file BacklinkCache.php.
|
protected |
Partition a DB result with backlinks in it into batches.
IResultWrapper | $res | Database result |
int | $batchSize | |
bool | $isComplete | Whether $res includes all the backlinks |
Definition at line 459 of file BacklinkCache.php.
|
protected |
Get the backlinks for a given table.
Cached in process memory only.
string | $table | |
int | bool | $startId | |
int | bool | $endId | |
int | $max | |
string | $select | 'all' or 'ids' |
Definition at line 176 of file BacklinkCache.php.
|
protected |
Contains the whole links from a database result.
This is raw data that will be partitioned in $partitionCache
Initialized with BacklinkCache::queryLinks()
Definition at line 86 of file BacklinkCache.php.
|
protected |
Local copy of a PageReference object.
Definition at line 98 of file BacklinkCache.php.
Referenced by __construct().
|
protected |
Multi dimensions array representing batches.
Keys are:
(string) links table name (int) batch size 'numRows' : Number of rows for this link table 'batches' : [ $start, $end ]
Definition at line 76 of file BacklinkCache.php.
|
protected |
Definition at line 89 of file BacklinkCache.php.
Referenced by __construct().
const BacklinkCache::CONSTRUCTOR_OPTIONS |
Definition at line 62 of file BacklinkCache.php.