From: Aaron Schulz Date: Tue, 20 Oct 2015 23:42:02 +0000 (-0700) Subject: Add IDatabase::isReadOnly() method X-Git-Tag: 1.31.0-rc.0~9322 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=7662212384f3e6eb7bff70c2a4108e4839395e62;p=lhc%2Fweb%2Fwiklou.git Add IDatabase::isReadOnly() method Also made getReadOnlyReason() protected as it has no outside callers and is not part of IDatabase. Change-Id: If6694a19df038af645a97f701397a536570d1b42 --- 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(); }