55 $this->mGoodLinks =
new HashBagOStuff( [
'maxKeys' => self::MAX_SIZE ] );
56 $this->mBadLinks =
new HashBagOStuff( [
'maxKeys' => self::MAX_SIZE ] );
58 $this->titleFormatter = $titleFormatter;
68 return MediaWikiServices::getInstance()->getLinkCache();
82 return wfSetVar( $this->mForUpdate, $update );
90 $info = $this->mGoodLinks->get( $title );
105 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
106 $info = $this->mGoodLinks->get( $dbkey );
110 return $info[$field];
119 return $this->mBadLinks->get( $title ) !==
false;
134 $revision = 0, $model =
null,
$lang =
null
136 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
137 $this->mGoodLinks->set( $dbkey, [
139 'length' => (
int)$len,
140 'redirect' => (
int)$redir,
141 'revision' => (
int)$revision,
142 'model' => $model ? (
string)$model :
null,
155 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
156 $this->mGoodLinks->set( $dbkey, [
157 'id' => intval( $row->page_id ),
158 'length' => intval( $row->page_len ),
159 'redirect' => intval( $row->page_is_redirect ),
160 'revision' => intval( $row->page_latest ),
161 'model' => !empty( $row->page_content_model ) ? strval( $row->page_content_model ) :
null,
162 'lang' => !empty( $row->page_lang ) ? strval( $row->page_lang ) :
null,
170 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
172 $this->mBadLinks->set( $dbkey, 1 );
180 $this->mBadLinks->delete( $title );
187 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
188 $this->mBadLinks->delete( $dbkey );
189 $this->mGoodLinks->delete( $dbkey );
200 $nt = Title::newFromDBkey( $title );
216 $fields = [
'page_id',
'page_len',
'page_is_redirect',
'page_latest' ];
218 $fields[] =
'page_content_model';
221 $fields[] =
'page_lang';
234 $key = $this->titleFormatter->getPrefixedDBkey( $nt );
235 if ( $this->
isBadLink( $key ) || $nt->isExternal()
250 if ( $this->mForUpdate ) {
255 $row =
$cache->getWithSetCallback(
256 $cache->makeKey(
'page', $nt->getNamespace(), sha1( $nt->getDBkey() ) ),
258 function ( $curValue, &$ttl, array &$setOpts ) use (
$cache, $nt ) {
260 $setOpts += Database::getCacheSetOptions(
$dbr );
263 $mtime = $row ?
wfTimestamp( TS_UNIX, $row->page_touched ) :
false;
264 $ttl =
$cache->adaptiveTTL( $mtime, $ttl );
275 $id = intval( $row->page_id );
292 return [
$cache->makeKey(
'page',
$t->getNamespace(), sha1(
$t->getDBkey() ) ) ];
303 $fields = self::getSelectFields();
305 $fields[] =
'page_touched';
311 [
'page_namespace' => $nt->getNamespace(),
'page_title' => $nt->getDBkey() ],
324 $cache = ObjectCache::getMainWANInstance();
326 $cache->makeKey(
'page', $title->getNamespace(), sha1( $title->getDBkey() ) )
335 $this->mGoodLinks->clear();
336 $this->mBadLinks->clear();
bool $wgPageLanguageUseDB
Enable page language feature Allows setting page language in database.
$wgContentHandlerUseDB
Set to false to disable use of the database fields introduced by the ContentHandler facility.
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.
Simple store for keeping values in an associative array for the current process.
Cache for article titles (prefixed DB keys) and ids linked from one source.
fetchPageRow(IDatabase $db, LinkTarget $nt)
HashBagOStuff $mGoodLinks
addLinkObj(LinkTarget $nt)
Add a title to the link cache, return the page_id or zero if non-existent.
TitleFormatter $titleFormatter
__construct(TitleFormatter $titleFormatter, WANObjectCache $cache)
addLink( $title)
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.
getMutableCacheKeys(WANObjectCache $cache, TitleValue $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.
static getSelectFields()
Fields that LinkCache needs to select.
clearLink(LinkTarget $target)
Represents a page (or page fragment) title within MediaWiki.
Multi-datacenter aware caching interface.
when a variable name is used in a function
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
if(!isset( $args[0])) $lang