Go to the documentation of this file.
74 wfDeprecated( __METHOD__ .
' with no NamespaceInfo argument',
'1.34' );
75 $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
77 $this->goodLinks =
new MapCacheLRU( self::MAX_SIZE );
78 $this->badLinks =
new MapCacheLRU( self::MAX_SIZE );
92 return MediaWikiServices::getInstance()->getLinkCache();
107 return wfSetVar( $this->mForUpdate, $update );
115 $info = $this->goodLinks->get(
$title );
130 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
131 $info = $this->goodLinks->get( $dbkey );
135 return $info[$field];
144 return $this->badLinks->has(
$title );
159 $revision = 0, $model =
null,
$lang =
null
161 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
162 $this->goodLinks->set( $dbkey, [
164 'length' => (
int)$len,
165 'redirect' => (
int)$redir,
166 'revision' => (
int)$revision,
167 'model' => $model ? (
string)$model :
null,
169 'restrictions' =>
null
181 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
182 $this->goodLinks->set( $dbkey, [
183 'id' => intval( $row->page_id ),
184 'length' => intval( $row->page_len ),
185 'redirect' => intval( $row->page_is_redirect ),
186 'revision' => intval( $row->page_latest ),
187 'model' => !empty( $row->page_content_model )
188 ? strval( $row->page_content_model )
190 'lang' => !empty( $row->page_lang )
191 ? strval( $row->page_lang )
193 'restrictions' => !empty( $row->page_restrictions )
194 ? strval( $row->page_restrictions )
203 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
205 $this->badLinks->set( $dbkey, 1 );
213 $this->badLinks->clear(
$title );
220 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
221 $this->badLinks->clear( $dbkey );
222 $this->goodLinks->clear( $dbkey );
240 'page_content_model',
244 $fields[] =
'page_lang';
257 $key = $this->titleFormatter->getPrefixedDBkey( $nt );
272 if ( $this->loadBalancer ===
null ) {
277 if ( $this->mForUpdate ) {
282 $row =
$cache->getWithSetCallback(
285 function ( $curValue, &$ttl, array &$setOpts ) use (
$cache, $nt ) {
287 $setOpts += Database::getCacheSetOptions(
$dbr );
290 $mtime = $row ?
wfTimestamp( TS_UNIX, $row->page_touched ) :
false;
291 $ttl =
$cache->adaptiveTTL( $mtime, $ttl );
302 $id = intval( $row->page_id );
319 return [
$cache->makeKey(
'page',
$t->getNamespace(), sha1(
$t->getDBkey() ) ) ];
326 $ns =
$title->getNamespace();
331 if ( $this->nsInfo->isContent( $ns ) ) {
335 return ( $ns >= 100 && $this->nsInfo->isSubject( $ns ) );
341 $fields[] =
'page_touched';
371 $this->goodLinks->clear();
372 $this->badLinks->clear();
__construct(TitleFormatter $titleFormatter, WANObjectCache $cache, NamespaceInfo $nsInfo=null, ILoadBalancer $loadBalancer=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.
static getSelectFields()
Fields that LinkCache needs to select.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
TitleFormatter $titleFormatter
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.
ILoadBalancer null $loadBalancer
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)