X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fexternalstore%2FExternalStoreDB.php;h=5edb4b2ef0f954937a52e092e847c81ada6800a8;hb=743eca95e3065abf3091d343a4ab88ee4508483a;hp=6bb1618ff6869bc158e9c5ac9348e660edfe2fa0;hpb=10d1b7d12b5d097413cd507740c5c71781c2580b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/externalstore/ExternalStoreDB.php b/includes/externalstore/ExternalStoreDB.php index 6bb1618ff6..5edb4b2ef0 100644 --- a/includes/externalstore/ExternalStoreDB.php +++ b/includes/externalstore/ExternalStoreDB.php @@ -20,13 +20,14 @@ * @file */ +use MediaWiki\MediaWikiServices; use Wikimedia\Rdbms\LoadBalancer; use Wikimedia\Rdbms\IDatabase; use Wikimedia\Rdbms\DBConnRef; use Wikimedia\Rdbms\MaintainableDBConnRef; /** - * DB accessable external objects. + * DB accessible external objects. * * In this system, each store "location" maps to a database "cluster". * The clusters must be defined in the normal LBFactory configuration. @@ -92,9 +93,8 @@ class ExternalStoreDB extends ExternalStoreMedium { public function store( $location, $data ) { $dbw = $this->getMaster( $location ); - $id = $dbw->nextSequenceValue( 'blob_blob_id_seq' ); $dbw->insert( $this->getTable( $dbw ), - [ 'blob_id' => $id, 'blob_text' => $data ], + [ 'blob_text' => $data ], __METHOD__ ); $id = $dbw->insertId(); if ( !$id ) { @@ -104,6 +104,10 @@ class ExternalStoreDB extends ExternalStoreMedium { return "DB://$location/$id"; } + public function isReadOnly( $location ) { + return ( $this->getLoadBalancer( $location )->getReadOnlyReason() !== false ); + } + /** * Get a LoadBalancer for the specified cluster * @@ -111,7 +115,8 @@ class ExternalStoreDB extends ExternalStoreMedium { * @return LoadBalancer */ private function getLoadBalancer( $cluster ) { - return wfGetLBFactory()->getExternalLB( $cluster ); + $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); + return $lbFactory->getExternalLB( $cluster ); } /**