Go to the documentation of this file.
63 wfDeprecated( __METHOD__ .
' with no NamespaceInfo argument',
'1.34' );
64 $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
66 $this->goodLinks =
new MapCacheLRU( self::MAX_SIZE );
67 $this->badLinks =
new MapCacheLRU( self::MAX_SIZE );
80 return MediaWikiServices::getInstance()->getLinkCache();
95 return wfSetVar( $this->mForUpdate, $update );
103 $info = $this->goodLinks->get(
$title );
118 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
119 $info = $this->goodLinks->get( $dbkey );
123 return $info[$field];
132 return $this->badLinks->has(
$title );
147 $revision = 0, $model =
null,
$lang =
null
149 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
150 $this->goodLinks->set( $dbkey, [
152 'length' => (
int)$len,
153 'redirect' => (
int)$redir,
154 'revision' => (
int)$revision,
155 'model' => $model ? (
string)$model :
null,
157 'restrictions' =>
null
169 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
170 $this->goodLinks->set( $dbkey, [
171 'id' => intval( $row->page_id ),
172 'length' => intval( $row->page_len ),
173 'redirect' => intval( $row->page_is_redirect ),
174 'revision' => intval( $row->page_latest ),
175 'model' => !empty( $row->page_content_model )
176 ? strval( $row->page_content_model )
178 'lang' => !empty( $row->page_lang )
179 ? strval( $row->page_lang )
181 'restrictions' => !empty( $row->page_restrictions )
182 ? strval( $row->page_restrictions )
191 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
193 $this->badLinks->set( $dbkey, 1 );
201 $this->badLinks->clear(
$title );
208 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
209 $this->badLinks->clear( $dbkey );
210 $this->goodLinks->clear( $dbkey );
230 $fields[] =
'page_content_model';
233 $fields[] =
'page_lang';
246 $key = $this->titleFormatter->getPrefixedDBkey( $nt );
260 if ( $this->mForUpdate ) {
265 $row =
$cache->getWithSetCallback(
268 function ( $curValue, &$ttl, array &$setOpts ) use (
$cache, $nt ) {
270 $setOpts += Database::getCacheSetOptions(
$dbr );
273 $mtime = $row ?
wfTimestamp( TS_UNIX, $row->page_touched ) :
false;
274 $ttl =
$cache->adaptiveTTL( $mtime, $ttl );
285 $id = intval( $row->page_id );
302 return [
$cache->makeKey(
'page',
$t->getNamespace(), sha1(
$t->getDBkey() ) ) ];
309 $ns =
$title->getNamespace();
314 if ( $this->nsInfo->isContent( $ns ) ) {
318 return ( $ns >= 100 && $this->nsInfo->isSubject( $ns ) );
324 $fields[] =
'page_touched';
354 $this->goodLinks->clear();
355 $this->badLinks->clear();
__construct(TitleFormatter $titleFormatter, WANObjectCache $cache, NamespaceInfo $nsInfo=null)
Cache for article titles (prefixed DB keys) and ids linked from one source.
addGoodLinkObjFromRow(LinkTarget $target, $row)
Same as above with better interface.
if(!isset( $args[0])) $lang
wfSetVar(&$dest, $source, $force=false)
Sets dest to source and returns the original value of dest If source is NULL, it just returns the val...
fetchPageRow(IDatabase $db, LinkTarget $nt)
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
getMutableCacheKeys(WANObjectCache $cache, LinkTarget $t)
getGoodLinkFieldObj(LinkTarget $target, $field)
Get a field of a title object from cache.
forUpdate( $update=null)
General accessor to get/set whether the master DB should be used.
$wgContentHandlerUseDB
Set to false to disable use of the database fields introduced by the ContentHandler facility.
static getSelectFields()
Fields that LinkCache needs to select.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
TitleFormatter $titleFormatter
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
addBadLinkObj(LinkTarget $target)
Handles a simple LRU key/value map with a maximum number of entries.
const MAX_SIZE
How many Titles to store.
bool $wgPageLanguageUseDB
Enable page language feature Allows setting page language in database.
isCacheable(LinkTarget $title)
Multi-datacenter aware caching interface.
invalidateTitle(LinkTarget $title)
Purge the link cache for a title.
static singleton()
Get an instance of this class.
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
addLinkObj(LinkTarget $nt)
Add a title to the link cache, return the page_id or zero if non-existent.
addGoodLinkObj( $id, LinkTarget $target, $len=-1, $redir=null, $revision=0, $model=null, $lang=null)
Add a link for the title to the link cache.
clearLink(LinkTarget $target)