54 $this->mGoodLinks =
new HashBagOStuff( [
'maxKeys' => self::MAX_SIZE ] );
55 $this->mBadLinks =
new HashBagOStuff( [
'maxKeys' => self::MAX_SIZE ] );
66 return MediaWikiServices::getInstance()->getLinkCache();
80 return wfSetVar( $this->mForUpdate, $update );
88 $info = $this->mGoodLinks->get(
$title );
103 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
104 $info = $this->mGoodLinks->get( $dbkey );
108 return $info[$field];
117 return $this->mBadLinks->get(
$title ) !==
false;
132 $revision = 0, $model = null,
$lang = null
134 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
135 $this->mGoodLinks->set( $dbkey, [
137 'length' => (
int)$len,
138 'redirect' => (
int)$redir,
139 'revision' => (
int)$revision,
140 'model' => $model ? (
string)$model : null,
153 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
154 $this->mGoodLinks->set( $dbkey, [
155 'id' => intval( $row->page_id ),
156 'length' => intval( $row->page_len ),
157 'redirect' => intval( $row->page_is_redirect ),
158 'revision' => intval( $row->page_latest ),
159 'model' => !empty( $row->page_content_model ) ? strval( $row->page_content_model ) : null,
160 'lang' => !empty( $row->page_lang ) ? strval( $row->page_lang ) : null,
168 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
170 $this->mBadLinks->set( $dbkey, 1 );
178 $this->mBadLinks->delete(
$title );
185 $dbkey = $this->titleFormatter->getPrefixedDBkey( $target );
186 $this->mBadLinks->delete( $dbkey );
187 $this->mGoodLinks->delete( $dbkey );
214 $fields = [
'page_id',
'page_len',
'page_is_redirect',
'page_latest' ];
215 if ( $wgContentHandlerUseDB ) {
216 $fields[] =
'page_content_model';
218 if ( $wgPageLanguageUseDB ) {
219 $fields[] =
'page_lang';
232 $key = $this->titleFormatter->getPrefixedDBkey( $nt );
250 $row = $db->selectRow(
'page', self::getSelectFields(),
255 if ( $row !==
false ) {
257 $id = intval( $row->page_id );
270 $this->mGoodLinks->clear();
271 $this->mBadLinks->clear();
__construct(TitleFormatter $titleFormatter)
addLinkObj(LinkTarget $nt)
Add a title to the link cache, return the page_id or zero if non-existent.
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
addBadLinkObj(LinkTarget $target)
HashBagOStuff $mGoodLinks
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
if(!isset($args[0])) $lang
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 MediaWikiServices
when a variable name is used in a it is silently declared as a new local masking the global
forUpdate($update=null)
General accessor to get/set whether the master DB should be used.
clearLink(LinkTarget $target)
$wgContentHandlerUseDB
Set to false to disable use of the database fields introduced by the ContentHandler facility...
TitleFormatter $titleFormatter
static singleton()
Get an instance of this class.
static newFromDBkey($key)
Create a new Title from a prefixed DB key.
getGoodLinkFieldObj(LinkTarget $target, $field)
Get a field of a title object from cache.
Allows to change the fields on the form that will be generated are created Can be used to omit specific feeds from being outputted You must not use this hook to add use OutputPage::addFeedLink() instead.&$feedLinks conditions will AND in the final query as a Content object as a Content object $title
const MAX_SIZE
How many Titles to store.
addLink($title)
Add a title to the link cache, return the page_id or zero if non-existent.
static getSelectFields()
Fields that LinkCache needs to select.
bool $wgPageLanguageUseDB
Enable page language feature Allows setting page language in database.
addGoodLinkObj($id, LinkTarget $target, $len=-1, $redir=null, $revision=0, $model=null, $lang=null)
Add a link for the title to the link cache.
Simple store for keeping values in an associative array for the current process.
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
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...
Cache for article titles (prefixed DB keys) and ids linked from one source.
addGoodLinkObjFromRow(LinkTarget $target, $row)
Same as above with better interface.