From 7662212384f3e6eb7bff70c2a4108e4839395e62 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 20 Oct 2015 16:42:02 -0700 Subject: [PATCH] Add IDatabase::isReadOnly() method Also made getReadOnlyReason() protected as it has no outside callers and is not part of IDatabase. Change-Id: If6694a19df038af645a97f701397a536570d1b42 --- includes/db/DBConnRef.php | 4 ++++ includes/db/Database.php | 7 +++++-- includes/db/IDatabase.php | 6 ++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/includes/db/DBConnRef.php b/includes/db/DBConnRef.php index 5a8fe920c1..53e9a50bb4 100644 --- a/includes/db/DBConnRef.php +++ b/includes/db/DBConnRef.php @@ -513,6 +513,10 @@ class DBConnRef implements IDatabase { return $this->__call( __FUNCTION__, func_get_args() ); } + public function isReadOnly() { + return $this->__call( __FUNCTION__, func_get_args() ); + } + /** * Clean up the connection when out of scope */ diff --git a/includes/db/Database.php b/includes/db/Database.php index 49a53ef30c..2f135a4c5c 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -4286,11 +4286,14 @@ abstract class DatabaseBase implements IDatabase { // no-op } + public function isReadOnly() { + return ( $this->getReadOnlyReason() !== false ); + } + /** * @return string|bool Reason this DB is read-only or false if it is not - * @since 1.27 */ - public function getReadOnlyReason() { + protected function getReadOnlyReason() { $reason = $this->getLBInfo( 'readOnlyReason' ); return is_string( $reason ) ? $reason : false; diff --git a/includes/db/IDatabase.php b/includes/db/IDatabase.php index ba3c1ddd56..d11058307d 100644 --- a/includes/db/IDatabase.php +++ b/includes/db/IDatabase.php @@ -1511,4 +1511,10 @@ interface IDatabase { * restore the initial value */ public function setBigSelects( $value = true ); + + /** + * @return bool Whether this DB is read-only + * @since 1.27 + */ + public function isReadOnly(); } -- 2.20.1