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 );
69 $this->titleFormatter = $titleFormatter;
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 );
228 'page_content_model',
232 $fields[] =
'page_lang';
245 $key = $this->titleFormatter->getPrefixedDBkey( $nt );
259 if ( $this->mForUpdate ) {
264 $row =
$cache->getWithSetCallback(
267 function ( $curValue, &$ttl, array &$setOpts ) use (
$cache, $nt ) {
269 $setOpts += Database::getCacheSetOptions(
$dbr );
272 $mtime = $row ?
wfTimestamp( TS_UNIX, $row->page_touched ) :
false;
273 $ttl =
$cache->adaptiveTTL( $mtime, $ttl );
284 $id = intval( $row->page_id );
301 return [
$cache->makeKey(
'page',
$t->getNamespace(), sha1(
$t->getDBkey() ) ) ];
308 $ns =
$title->getNamespace();
313 if ( $this->nsInfo->isContent( $ns ) ) {
317 return ( $ns >= 100 && $this->nsInfo->isSubject( $ns ) );
321 $fields = self::getSelectFields();
323 $fields[] =
'page_touched';
353 $this->goodLinks->clear();
354 $this->badLinks->clear();
bool $wgPageLanguageUseDB
Enable page language feature Allows setting page language in database.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
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...
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
Cache for article titles (prefixed DB keys) and ids linked from one source.
fetchPageRow(IDatabase $db, LinkTarget $nt)
addLinkObj(LinkTarget $nt)
Add a title to the link cache, return the page_id or zero if non-existent.
TitleFormatter $titleFormatter
addGoodLinkObj( $id, LinkTarget $target, $len=-1, $redir=null, $revision=0, $model=null, $lang=null)
Add a link for the title to the link cache.
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.
invalidateTitle(LinkTarget $title)
Purge the link cache for a title.
isCacheable(LinkTarget $title)
addGoodLinkObjFromRow(LinkTarget $target, $row)
Same as above with better interface.
static singleton()
Get an instance of this class.
addBadLinkObj(LinkTarget $target)
const MAX_SIZE
How many Titles to store.
__construct(TitleFormatter $titleFormatter, WANObjectCache $cache, NamespaceInfo $nsInfo=null)
static getSelectFields()
Fields that LinkCache needs to select.
clearLink(LinkTarget $target)
Handles a simple LRU key/value map with a maximum number of entries.
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Multi-datacenter aware caching interface.
if(!isset( $args[0])) $lang