52 $this->mGoodLinks =
new HashBagOStuff( [
'maxKeys' => self::MAX_SIZE ] );
53 $this->mBadLinks =
new HashBagOStuff( [
'maxKeys' => self::MAX_SIZE ] );
62 if ( !self::$instance ) {
66 return self::$instance;
77 self::$instance = null;
104 return wfSetVar( $this->mForUpdate, $update );
112 $info = $this->mGoodLinks->get(
$title );
128 $info = $this->mGoodLinks->get( $dbkey );
132 return $info[$field];
141 return $this->mBadLinks->get(
$title ) !==
false;
156 $revision = 0, $model = null,
$lang = null
159 $this->mGoodLinks->set( $dbkey, [
161 'length' => (
int)$len,
162 'redirect' => (
int)$redir,
163 'revision' => (
int)$revision,
164 'model' => $model ? (
string)$model : null,
178 $this->mGoodLinks->set( $dbkey, [
179 'id' => intval( $row->page_id ),
180 'length' => intval( $row->page_len ),
181 'redirect' => intval( $row->page_is_redirect ),
182 'revision' => intval( $row->page_latest ),
183 'model' => !empty( $row->page_content_model ) ? strval( $row->page_content_model ) : null,
184 'lang' => !empty( $row->page_lang ) ? strval( $row->page_lang ) : null,
194 $this->mBadLinks->set( $dbkey, 1 );
202 $this->mBadLinks->delete(
$title );
210 $this->mBadLinks->delete( $dbkey );
211 $this->mGoodLinks->delete( $dbkey );
235 global $wgContentHandlerUseDB, $wgPageLanguageUseDB;
253 $fields = [
'page_id',
'page_len',
'page_is_redirect',
'page_latest' ];
254 if ( $wgContentHandlerUseDB ) {
255 $fields[] =
'page_content_model';
257 if ( $wgPageLanguageUseDB ) {
258 $fields[] =
'page_lang';
261 $row = $db->selectRow(
'page', $fields,
266 if ( $row !==
false ) {
268 $id = intval( $row->page_id );
281 $this->mGoodLinks->clear();
282 $this->mBadLinks->clear();
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
magic word the default is to use $key to get the and $key value or $key value text $key value html to format the value $key
getGoodLinkFieldObj(Title $title, $field)
Get a field of a title object from cache.
HashBagOStuff $mGoodLinks
if(!isset($args[0])) $lang
addGoodLinkObjFromRow(Title $title, $row)
Same as above with better interface.
Represents a title within MediaWiki.
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.
isExternal()
Is this Title interwiki?
static LinkCache $instance
static singleton()
Get an instance of this class.
getDBkey()
Get the main part with underscores.
static newFromDBkey($key)
Create a new Title from a prefixed DB key.
namespace and then decline to actually register it file or subcat img or subcat $title
static setSingleton(LinkCache $instance)
Set the singleton instance to a given object.
getNamespace()
Get the namespace index, i.e.
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.
addLinkObj(Title $nt)
Add a title to the link cache, return the page_id or zero if non-existent.
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.
static destroySingleton()
Destroy the singleton instance.
addGoodLinkObj($id, Title $title, $len=-1, $redir=null, $revision=0, $model=null, $lang=null)
Add a link for the title to the link cache.
addBadLinkObj(Title $title)
getPrefixedDBkey()
Get the prefixed database key form.