From 2f8e07cfcbb7b84f5aa32d8694e660e9d6e260b7 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 21 Aug 2019 17:35:02 -0700 Subject: [PATCH] maintenance: Sanity check that --replicadb isn't using the master in sql.php Change-Id: I0b7fd896c88b06cbc17b31b1ae2b9cb8e375da1b --- maintenance/sql.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maintenance/sql.php b/maintenance/sql.php index 21d8b2dd45..612c09264c 100644 --- a/maintenance/sql.php +++ b/maintenance/sql.php @@ -67,7 +67,7 @@ class MwSql extends Maintenance { $replicaDB = $this->getOption( 'replicadb', $this->getOption( 'slave', '' ) ); if ( $replicaDB === 'any' ) { $index = DB_REPLICA; - } elseif ( $replicaDB != '' ) { + } elseif ( $replicaDB !== '' ) { $index = null; $serverCount = $lb->getServerCount(); for ( $i = 0; $i < $serverCount; ++$i ) { @@ -76,7 +76,7 @@ class MwSql extends Maintenance { break; } } - if ( $index === null ) { + if ( $index === null || $index === $lb->getWriterIndex() ) { $this->fatalError( "No replica DB server configured with the name '$replicaDB'." ); } } else { -- 2.20.1