MediaWiki  1.23.1
ForeignDBRepo.php
Go to the documentation of this file.
1 <?php
29 class ForeignDBRepo extends LocalRepo {
31  protected $dbType;
32 
34  protected $dbServer;
35 
37  protected $dbUser;
38 
40  protected $dbPassword;
41 
43  protected $dbName;
44 
46  protected $dbFlags;
47 
49  protected $tablePrefix;
50 
52  protected $hasSharedCache;
53 
54  # Other stuff
55  protected $dbConn;
56  protected $fileFactory = array( 'ForeignDBFile', 'newFromTitle' );
57  protected $fileFromRowFactory = array( 'ForeignDBFile', 'newFromRow' );
58 
62  function __construct( $info ) {
63  parent::__construct( $info );
64  $this->dbType = $info['dbType'];
65  $this->dbServer = $info['dbServer'];
66  $this->dbUser = $info['dbUser'];
67  $this->dbPassword = $info['dbPassword'];
68  $this->dbName = $info['dbName'];
69  $this->dbFlags = $info['dbFlags'];
70  $this->tablePrefix = $info['tablePrefix'];
71  $this->hasSharedCache = $info['hasSharedCache'];
72  }
73 
77  function getMasterDB() {
78  if ( !isset( $this->dbConn ) ) {
79  $this->dbConn = DatabaseBase::factory( $this->dbType,
80  array(
81  'host' => $this->dbServer,
82  'user' => $this->dbUser,
83  'password' => $this->dbPassword,
84  'dbname' => $this->dbName,
85  'flags' => $this->dbFlags,
86  'tablePrefix' => $this->tablePrefix,
87  'foreign' => true,
88  )
89  );
90  }
91 
92  return $this->dbConn;
93  }
94 
98  function getSlaveDB() {
99  return $this->getMasterDB();
100  }
101 
105  function hasSharedCache() {
106  return $this->hasSharedCache;
107  }
108 
115  function getSharedCacheKey( /*...*/ ) {
116  if ( $this->hasSharedCache() ) {
117  $args = func_get_args();
118  array_unshift( $args, $this->dbName, $this->tablePrefix );
119 
120  return call_user_func_array( 'wfForeignMemcKey', $args );
121  } else {
122  return false;
123  }
124  }
125 
126  protected function assertWritableRepo() {
127  throw new MWException( get_class( $this ) . ': write operations are not supported.' );
128  }
129 
136  function getInfo() {
137  return FileRepo::getInfo();
138  }
139 }
ForeignDBRepo\$dbUser
string $dbUser
Definition: ForeignDBRepo.php:34
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
ForeignDBRepo\getInfo
getInfo()
Return information about the repository.
Definition: ForeignDBRepo.php:128
ForeignDBRepo\$hasSharedCache
bool $hasSharedCache
Definition: ForeignDBRepo.php:44
ForeignDBRepo\$dbName
string $dbName
Definition: ForeignDBRepo.php:38
ForeignDBRepo\$dbConn
$dbConn
Definition: ForeignDBRepo.php:47
FileRepo\getInfo
getInfo()
Return information about the repository.
Definition: FileRepo.php:1846
ForeignDBRepo\assertWritableRepo
assertWritableRepo()
Throw an exception if this repo is read-only by design.
Definition: ForeignDBRepo.php:118
ForeignDBRepo\$dbServer
string $dbServer
Definition: ForeignDBRepo.php:32
MWException
MediaWiki exception.
Definition: MWException.php:26
ForeignDBRepo\$dbPassword
string $dbPassword
Definition: ForeignDBRepo.php:36
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
DatabaseBase\factory
static factory( $dbType, $p=array())
Given a DB type, construct the name of the appropriate child class of DatabaseBase.
Definition: Database.php:808
ForeignDBRepo\$tablePrefix
string $tablePrefix
Definition: ForeignDBRepo.php:42
ForeignDBRepo\hasSharedCache
hasSharedCache()
Definition: ForeignDBRepo.php:97
ForeignDBRepo
A foreign repository with an accessible MediaWiki database.
Definition: ForeignDBRepo.php:29
ForeignDBRepo\getMasterDB
getMasterDB()
Definition: ForeignDBRepo.php:69
ForeignDBRepo\getSharedCacheKey
getSharedCacheKey()
Get a key on the primary cache for this repository.
Definition: ForeignDBRepo.php:107
$args
if( $line===false) $args
Definition: cdb.php:62
ForeignDBRepo\$dbType
string $dbType
Definition: ForeignDBRepo.php:30
ForeignDBRepo\$dbFlags
string $dbFlags
Definition: ForeignDBRepo.php:40
ForeignDBRepo\getSlaveDB
getSlaveDB()
Definition: ForeignDBRepo.php:90
ForeignDBRepo\__construct
__construct( $info)
Definition: ForeignDBRepo.php:54
ForeignDBRepo\$fileFactory
$fileFactory
Definition: ForeignDBRepo.php:48
ForeignDBRepo\$fileFromRowFactory
$fileFromRowFactory
Definition: ForeignDBRepo.php:49
LocalRepo
A repository that stores files in the local filesystem and registers them in the wiki's own database.
Definition: LocalRepo.php:31