From b9ac05614082faf75060e9e4aa0303cb1eb4c34b Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Mon, 3 Oct 2011 13:19:22 +0000 Subject: [PATCH] Merge r97687 --- includes/ExternalStoreDB.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/includes/ExternalStoreDB.php b/includes/ExternalStoreDB.php index 877277a280..552c310992 100644 --- a/includes/ExternalStoreDB.php +++ b/includes/ExternalStoreDB.php @@ -18,7 +18,7 @@ class ExternalStoreDB { */ function &getLoadBalancer( $cluster ) { $wiki = isset($this->mParams['wiki']) ? $this->mParams['wiki'] : false; - + return wfGetLBFactory()->getExternalLB( $cluster, $wiki ); } @@ -29,8 +29,18 @@ class ExternalStoreDB { * @return DatabaseBase object */ function &getSlave( $cluster ) { + global $wgDefaultExternalStore; + $wiki = isset($this->mParams['wiki']) ? $this->mParams['wiki'] : false; $lb =& $this->getLoadBalancer( $cluster ); + + if ( !in_array( "DB://" . $cluster, $wgDefaultExternalStore ) ) { + wfDebug( "read only external store" ); + $lb->allowLagged(true); + } else { + wfDebug( "writable external store" ); + } + return $lb->getConnection( DB_SLAVE, array(), $wiki ); } @@ -139,8 +149,8 @@ class ExternalStoreDB { function store( $cluster, $data ) { $dbw = $this->getMaster( $cluster ); $id = $dbw->nextSequenceValue( 'blob_blob_id_seq' ); - $dbw->insert( $this->getTable( $dbw ), - array( 'blob_id' => $id, 'blob_text' => $data ), + $dbw->insert( $this->getTable( $dbw ), + array( 'blob_id' => $id, 'blob_text' => $data ), __METHOD__ ); $id = $dbw->insertId(); if ( !$id ) { -- 2.20.1