Fix condition if...else in getDB() & PHPDoc comment for getUserDB()
[lhc/web/wiklou.git] / maintenance / Maintenance.php
index 6219476..f3c2e12 100644 (file)
@@ -23,7 +23,7 @@
 // Bail on old versions of PHP, or if composer has not been run yet to install
 // dependencies.
 require_once __DIR__ . '/../includes/PHPVersionCheck.php';
-wfEntryPointCheck( 'cli' );
+wfEntryPointCheck( 'text' );
 
 use MediaWiki\Shell\Shell;
 
@@ -1326,7 +1326,6 @@ abstract class Maintenance {
                        $this->output( "done.\n" );
                }
 
-               # Done
                $this->commitTransaction( $dbw, __METHOD__ );
        }
 
@@ -1349,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;
        }
 
        /**
@@ -1699,13 +1697,9 @@ abstract class LoggedUpdateMaintenance extends Maintenance {
                        return false;
                }
 
-               if ( $db->insert( 'updatelog', [ 'ul_key' => $key ], __METHOD__, 'IGNORE' ) ) {
-                       return true;
-               } else {
-                       $this->output( $this->updatelogFailedMessage() . "\n" );
+               $db->insert( 'updatelog', [ 'ul_key' => $key ], __METHOD__, 'IGNORE' );
 
-                       return false;
-               }
+               return true;
        }
 
        /**
@@ -1718,16 +1712,6 @@ abstract class LoggedUpdateMaintenance extends Maintenance {
                return "Update '{$key}' already logged as completed.";
        }
 
-       /**
-        * Message to show that the update log was unable to log the completion of this update
-        * @return string
-        */
-       protected function updatelogFailedMessage() {
-               $key = $this->getUpdateKey();
-
-               return "Unable to log update '{$key}' as completed.";
-       }
-
        /**
         * Do the actual work. All child classes will need to implement this.
         * Return true to log the update as done or false (usually on failure).