Fix condition if...else in getDB() & PHPDoc comment for getUserDB()
authorDerick Alangi <alangiderick@gmail.com>
Mon, 4 Feb 2019 12:45:39 +0000 (13:45 +0100)
committerD3r1ck01 <alangiderick@gmail.com>
Wed, 6 Feb 2019 09:50:59 +0000 (09:50 +0000)
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

maintenance/Maintenance.php
maintenance/includes/DeleteLocalPasswords.php

index 71d12ee..f3c2e12 100644 (file)
@@ -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;
        }
 
        /**
index 747319d..b964417 100644 (file)
@@ -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 );