Merge "Add checkDependencies.php"
[lhc/web/wiklou.git] / includes / externalstore / ExternalStoreDB.php
index 5a77e89..cac16b6 100644 (file)
@@ -106,7 +106,9 @@ class ExternalStoreDB extends ExternalStoreMedium {
        }
 
        public function isReadOnly( $location ) {
-               return ( $this->getLoadBalancer( $location )->getReadOnlyReason() !== false );
+               $lb = $this->getLoadBalancer( $location );
+               $domainId = $this->getDomainId( $lb->getServerInfo( $lb->getWriterIndex() ) );
+               return ( $lb->getReadOnlyReason( $domainId ) !== false );
        }
 
        /**
@@ -166,6 +168,10 @@ class ExternalStoreDB extends ExternalStoreMedium {
         * @return string|bool Database domain ID or false
         */
        private function getDomainId( array $server ) {
+               if ( isset( $this->params['wiki'] ) && $this->params['wiki'] !== false ) {
+                       return $this->params['wiki']; // explicit domain
+               }
+
                if ( isset( $server['dbname'] ) ) {
                        // T200471: for b/c, treat any "dbname" field as forcing which database to use.
                        // MediaWiki/LoadBalancer previously did not enforce any concept of a local DB
@@ -181,7 +187,7 @@ class ExternalStoreDB extends ExternalStoreMedium {
                        return $domain->getId();
                }
 
-               return $this->params['wiki'] ?? false; // local domain unless explictly given
+               return false; // local LB domain
        }
 
        /**