Fix populateContentTables.php with no rows
authorBrad Jorsch <bjorsch@wikimedia.org>
Wed, 11 Jul 2018 19:00:41 +0000 (15:00 -0400)
committerReedy <reedy@wikimedia.org>
Thu, 12 Jul 2018 17:34:18 +0000 (17:34 +0000)
MIN() and MAX() return null if there are no rows. Fill in a dummy row in
that case.

Change-Id: I7caba98a5ec30e15e19d49effa22a70c78a71c28

maintenance/populateContentTables.php

index 5322b5b..20d6b8b 100644 (file)
@@ -188,6 +188,11 @@ class PopulateContentTables extends Maintenance {
                        '',
                        __METHOD__
                );
+               if ( !$minmax || !is_numeric( $minmax->min ) || !is_numeric( $minmax->max ) ) {
+                       // No rows?
+                       $minmax = (object)[ 'min' => 1, 'max' => 0 ];
+               }
+
                $batchSize = $this->getBatchSize();
 
                for ( $startId = $minmax->min; $startId <= $minmax->max; $startId += $batchSize ) {