Avoid using return value of IDatabase::insert()
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 26 Oct 2018 22:42:26 +0000 (15:42 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Sun, 28 Oct 2018 22:14:07 +0000 (22:14 +0000)
Change-Id: I5992e4f03cd522b25607947291795d1da60d0291

maintenance/Maintenance.php
maintenance/populateCategory.php

index 6219476..c786ce8 100644 (file)
@@ -1699,13 +1699,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 +1714,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).
index f2a0007..f07bc55 100644 (file)
@@ -133,20 +133,14 @@ TEXT
                        usleep( $throttle * 1000 );
                }
 
-               if ( $dbw->insert(
+               $dbw->insert(
                        'updatelog',
                        [ 'ul_key' => 'populate category' ],
                        __METHOD__,
                        'IGNORE'
-               ) ) {
-                       $this->output( "Category population complete.\n" );
-
-                       return true;
-               } else {
-                       $this->output( "Could not insert category population row.\n" );
+               );
 
-                       return false;
-               }
+               return true;
        }
 }