MediaWiki  REL1_19
ForeignDBRepo.php
Go to the documentation of this file.
00001 <?php
00014 class ForeignDBRepo extends LocalRepo {
00015         # Settings
00016         var $dbType, $dbServer, $dbUser, $dbPassword, $dbName, $dbFlags,
00017                 $tablePrefix, $hasSharedCache;
00018 
00019         # Other stuff
00020         var $dbConn;
00021         var $fileFactory = array( 'ForeignDBFile', 'newFromTitle' );
00022         var $fileFromRowFactory = array( 'ForeignDBFile', 'newFromRow' );
00023 
00024         function __construct( $info ) {
00025                 parent::__construct( $info );
00026                 $this->dbType = $info['dbType'];
00027                 $this->dbServer = $info['dbServer'];
00028                 $this->dbUser = $info['dbUser'];
00029                 $this->dbPassword = $info['dbPassword'];
00030                 $this->dbName = $info['dbName'];
00031                 $this->dbFlags = $info['dbFlags'];
00032                 $this->tablePrefix = $info['tablePrefix'];
00033                 $this->hasSharedCache = $info['hasSharedCache'];
00034         }
00035 
00036         function getMasterDB() {
00037                 if ( !isset( $this->dbConn ) ) {
00038                         $this->dbConn = DatabaseBase::factory( $this->dbType,
00039                                 array(
00040                                         'host' => $this->dbServer,
00041                                         'user'   => $this->dbUser,
00042                                         'password' => $this->dbPassword,
00043                                         'dbname' => $this->dbName,
00044                                         'flags' => $this->dbFlags,
00045                                         'tablePrefix' => $this->tablePrefix
00046                                 )
00047                         );
00048                 }
00049                 return $this->dbConn;
00050         }
00051 
00052         function getSlaveDB() {
00053                 return $this->getMasterDB();
00054         }
00055 
00056         function hasSharedCache() {
00057                 return $this->hasSharedCache;
00058         }
00059 
00065         function getSharedCacheKey( /*...*/ ) {
00066                 if ( $this->hasSharedCache() ) {
00067                         $args = func_get_args();
00068                         array_unshift( $args, $this->dbName, $this->tablePrefix );
00069                         return call_user_func_array( 'wfForeignMemcKey', $args );
00070                 } else {
00071                         return false;
00072                 }
00073         }
00074 
00075         function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) {
00076                 throw new MWException( get_class($this) . ': write operations are not supported' );
00077         }
00078         function publish( $srcPath, $dstRel, $archiveRel, $flags = 0 ) {
00079                 throw new MWException( get_class($this) . ': write operations are not supported' );
00080         }
00081         function deleteBatch( $sourceDestPairs ) {
00082                 throw new MWException( get_class($this) . ': write operations are not supported' );
00083         }
00084 }