MediaWiki REL1_33
ForeignDBViaLBRepo.php
Go to the documentation of this file.
1<?php
27
35 protected $wiki;
36
38 protected $fileFactory = [ ForeignDBFile::class, 'newFromTitle' ];
39
41 protected $fileFromRowFactory = [ ForeignDBFile::class, 'newFromRow' ];
42
44 protected $hasSharedCache;
45
49 function __construct( $info ) {
50 parent::__construct( $info );
51 $this->wiki = $info['wiki'];
52 $this->hasSharedCache = $info['hasSharedCache'];
53 }
54
58 function getMasterDB() {
59 return $this->getDBLoadBalancer()->getConnectionRef( DB_MASTER, [], $this->wiki );
60 }
61
65 function getReplicaDB() {
66 return $this->getDBLoadBalancer()->getConnectionRef( DB_REPLICA, [], $this->wiki );
67 }
68
72 protected function getDBFactory() {
73 return function ( $index ) {
74 return $this->getDBLoadBalancer()->getConnectionRef( $index, [], $this->wiki );
75 };
76 }
77
81 protected function getDBLoadBalancer() {
82 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
83
84 return $lbFactory->getMainLB( $this->wiki );
85 }
86
87 function hasSharedCache() {
89 }
90
97 function getSharedCacheKey( /*...*/ ) {
98 if ( $this->hasSharedCache() ) {
99 $args = func_get_args();
100 array_unshift( $args, $this->wiki );
101
102 return implode( ':', $args );
103 } else {
104 return false;
105 }
106 }
107
108 protected function assertWritableRepo() {
109 throw new MWException( static::class . ': write operations are not supported.' );
110 }
111
112 public function getInfo() {
113 return FileRepo::getInfo();
114 }
115}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
if( $line===false) $args
Definition cdb.php:64
getInfo()
Return information about the repository.
A foreign repository with a MediaWiki database accessible via the configured LBFactory.
getInfo()
Return information about the repository.
getSharedCacheKey()
Get a key on the primary cache for this repository.
assertWritableRepo()
Throw an exception if this repo is read-only by design.
A repository that stores files in the local filesystem and registers them in the wiki's own database.
Definition LocalRepo.php:36
MediaWiki exception.
MediaWikiServices is the service locator for the application scope of MediaWiki.
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
Definition injection.txt:37
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38
Database cluster connection, tracking, load balancing, and transaction manager interface.
Prior to maintenance scripts were a hodgepodge of code that had no cohesion or formal method of action Beginning maintenance scripts have been cleaned up to use a unified class Directory structure How to run a script How to write your own DIRECTORY STRUCTURE The maintenance directory of a MediaWiki installation contains several all of which have unique purposes HOW TO RUN A SCRIPT Ridiculously just call php someScript php that s in the top level maintenance directory if not default wiki
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
const DB_REPLICA
Definition defines.php:25
const DB_MASTER
Definition defines.php:26