ForeignDBRepo.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * A foreign repository with an accessible MediaWiki database
  4. * @ingroup FileRepo
  5. */
  6. class ForeignDBRepo extends LocalRepo {
  7. # Settings
  8. var $dbType, $dbServer, $dbUser, $dbPassword, $dbName, $dbFlags,
  9. $tablePrefix, $hasSharedCache;
  10. # Other stuff
  11. var $dbConn;
  12. var $fileFactory = array( 'ForeignDBFile', 'newFromTitle' );
  13. var $fileFromRowFactory = array( 'ForeignDBFile', 'newFromRow' );
  14. function __construct( $info ) {
  15. parent::__construct( $info );
  16. $this->dbType = $info['dbType'];
  17. $this->dbServer = $info['dbServer'];
  18. $this->dbUser = $info['dbUser'];
  19. $this->dbPassword = $info['dbPassword'];
  20. $this->dbName = $info['dbName'];
  21. $this->dbFlags = $info['dbFlags'];
  22. $this->tablePrefix = $info['tablePrefix'];
  23. $this->hasSharedCache = $info['hasSharedCache'];
  24. }
  25. function getMasterDB() {
  26. if ( !isset( $this->dbConn ) ) {
  27. $class = 'Database' . ucfirst( $this->dbType );
  28. $this->dbConn = new $class( $this->dbServer, $this->dbUser,
  29. $this->dbPassword, $this->dbName, false, $this->dbFlags,
  30. $this->tablePrefix );
  31. }
  32. return $this->dbConn;
  33. }
  34. function getSlaveDB() {
  35. return $this->getMasterDB();
  36. }
  37. function hasSharedCache() {
  38. return $this->hasSharedCache;
  39. }
  40. function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) {
  41. throw new MWException( get_class($this) . ': write operations are not supported' );
  42. }
  43. function publish( $srcPath, $dstRel, $archiveRel, $flags = 0 ) {
  44. throw new MWException( get_class($this) . ': write operations are not supported' );
  45. }
  46. function deleteBatch( $fileMap ) {
  47. throw new MWException( get_class($this) . ': write operations are not supported' );
  48. }
  49. }