52 $this->mGoodLinks =
new HashBagOStuff( [
'maxKeys' => self::MAX_SIZE ] );
53 $this->mBadLinks =
new HashBagOStuff( [
'maxKeys' => self::MAX_SIZE ] );
55 $this->titleFormatter = $titleFormatter;
65 return MediaWikiServices::getInstance()->getLinkCache();
79 return wfSetVar( $this->mForUpdate, $update );
87 $info = $this->mGoodLinks->get(
$title );
102 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
103 $info = $this->mGoodLinks->get( $dbkey );
107 return $info[$field];
116 return $this->mBadLinks->get(
$title ) !==
false;
131 $revision = 0, $model =
null,
$lang =
null
133 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
134 $this->mGoodLinks->set( $dbkey, [
136 'length' => (
int)$len,
137 'redirect' => (
int)$redir,
138 'revision' => (
int)$revision,
139 'model' => $model ? (
string)$model :
null,
152 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
153 $this->mGoodLinks->set( $dbkey, [
154 'id' => intval( $row->page_id ),
155 'length' => intval( $row->page_len ),
156 'redirect' => intval( $row->page_is_redirect ),
157 'revision' => intval( $row->page_latest ),
158 'model' => !empty( $row->page_content_model ) ? strval( $row->page_content_model ) :
null,
159 'lang' => !empty( $row->page_lang ) ? strval( $row->page_lang ) :
null,
167 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
169 $this->mBadLinks->set( $dbkey, 1 );
177 $this->mBadLinks->delete(
$title );
184 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
185 $this->mBadLinks->delete( $dbkey );
186 $this->mGoodLinks->delete( $dbkey );
197 $nt = Title::newFromDBkey(
$title );
213 $fields = [
'page_id',
'page_len',
'page_is_redirect',
'page_latest' ];
215 $fields[] =
'page_content_model';
218 $fields[] =
'page_lang';
231 $key = $this->titleFormatter->getPrefixedDBkey( $nt );
247 if ( $this->mForUpdate ) {
252 $row =
$cache->getWithSetCallback(
257 $setOpts += Database::getCacheSetOptions(
$dbr );
261 $ttl =
$cache->adaptiveTTL( $mtime, $ttl );
272 $id = intval( $row->page_id );
286 $fields = self::getSelectFields();
288 $fields[] =
'page_touched';
307 $cache = ObjectCache::getMainWANInstance();
318 $this->mGoodLinks->clear();
319 $this->mBadLinks->clear();
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
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.
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)
Multi-datacenter aware caching interface.
when a variable name is used in a function
when a variable name is used in a it is silently declared as a new local masking the global
the array() calling protocol came about after MediaWiki 1.4rc1.
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
namespace and then decline to actually register it file or subcat img or subcat $title
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Basic database interface for live and lazy-loaded relation database handles.
selectRow( $table, $vars, $conds, $fname=__METHOD__, $options=[], $join_conds=[])
Single row SELECT wrapper.
if(!isset( $args[0])) $lang
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.