MediaWiki  1.27.3
ForeignDBViaLBRepo.php
Go to the documentation of this file.
1 <?php
31  protected $wiki;
32 
34  protected $dbName;
35 
37  protected $tablePrefix;
38 
40  protected $fileFactory = [ 'ForeignDBFile', 'newFromTitle' ];
41 
43  protected $fileFromRowFactory = [ 'ForeignDBFile', 'newFromRow' ];
44 
48  function __construct( $info ) {
49  parent::__construct( $info );
50  $this->wiki = $info['wiki'];
51  list( $this->dbName, $this->tablePrefix ) = wfSplitWikiID( $this->wiki );
52  $this->hasSharedCache = $info['hasSharedCache'];
53  }
54 
58  function getMasterDB() {
59  return wfGetDB( DB_MASTER, [], $this->wiki );
60  }
61 
65  function getSlaveDB() {
66  return wfGetDB( DB_SLAVE, [], $this->wiki );
67  }
68 
72  protected function getDBFactory() {
74  return function( $index ) use ( $wiki ) {
75  return wfGetDB( $index, [], $wiki );
76  };
77  }
78 
79  function hasSharedCache() {
80  return $this->hasSharedCache;
81  }
82 
89  function getSharedCacheKey( /*...*/ ) {
90  if ( $this->hasSharedCache() ) {
91  $args = func_get_args();
92  array_unshift( $args, $this->wiki );
93 
94  return implode( ':', $args );
95  } else {
96  return false;
97  }
98  }
99 
100  protected function assertWritableRepo() {
101  throw new MWException( get_class( $this ) . ': write operations are not supported.' );
102  }
103 
104  public function getInfo() {
105  return FileRepo::getInfo();
106  }
107 }
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
A repository that stores files in the local filesystem and registers them in the wiki's own database...
Definition: LocalRepo.php:31
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
Definition: maintenance.txt:1
if($line===false) $args
Definition: cdb.php:64
getInfo()
Return information about the repository.
Definition: FileRepo.php:1886
A foreign repository with a MediaWiki database accessible via the configured LBFactory.
getSharedCacheKey()
Get a key on the primary cache for this repository.
const DB_SLAVE
Definition: Defines.php:46
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:35
const DB_MASTER
Definition: Defines.php:47
wfSplitWikiID($wiki)
Split a wiki ID into DB name and table prefix.