From: Derick Alangi Date: Mon, 4 Feb 2019 12:45:39 +0000 (+0100) Subject: Fix condition if...else in getDB() & PHPDoc comment for getUserDB() X-Git-Tag: 1.34.0-rc.0~2922 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/pie.php?a=commitdiff_plain;h=027fb1c8cd366bba1fe8c3dbdd2a1331d70b7761;p=lhc%2Fweb%2Fwiklou.git Fix condition if...else in getDB() & PHPDoc comment for getUserDB() So the conditional check should by default return $this->mDb if it's not null, so, the else seems not to be needed(?). If we have a database handle to process the current batch, $this->getDB() will return IMaintainableDatabase but if it's not available (null), a call to $this->getDB() will return an instance of \Wikimedia\Rdbms\Database is returned instead. In accordance with the documentation (phpdoc), update the method getUserDB() to be compliant with callers return type. Change-Id: I95f3407dd2ffe8e4a1ad7a70be86b6cf3b65ff50 --- diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 71d12ee0bc..f3c2e12da2 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -1348,11 +1348,10 @@ abstract class Maintenance { * @return IMaintainableDatabase */ protected function getDB( $db, $groups = [], $wiki = false ) { - if ( is_null( $this->mDb ) ) { + if ( $this->mDb === null ) { return wfGetDB( $db, $groups, $wiki ); - } else { - return $this->mDb; } + return $this->mDb; } /** diff --git a/maintenance/includes/DeleteLocalPasswords.php b/maintenance/includes/DeleteLocalPasswords.php index 747319d6a2..b964417f35 100644 --- a/maintenance/includes/DeleteLocalPasswords.php +++ b/maintenance/includes/DeleteLocalPasswords.php @@ -105,6 +105,7 @@ ERROR /** * Get the master DB handle for the current user batch. This is provided for the benefit * of authentication extensions which subclass this and work with wiki farms. + * @return IMaintainableDatabase */ protected function getUserDB() { return $this->getDB( DB_MASTER );