From c2572eb67164b529516381c4bd5cf3af3067fa86 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 16 Jun 2014 14:46:09 -0700 Subject: [PATCH] Removed useless "while" loop Change-Id: Idc8ebc3a90f10f2179fcea0872207fe17cc2b265 --- maintenance/nextJobDB.php | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/maintenance/nextJobDB.php b/maintenance/nextJobDB.php index 21d9104213..d17236338c 100644 --- a/maintenance/nextJobDB.php +++ b/maintenance/nextJobDB.php @@ -57,28 +57,24 @@ class NextJobDB extends Maintenance { return; // no DBs with jobs or cache is both empty and locked } - do { - $again = false; - - $candidates = array(); // list of (type, db) - // Flatten the tree of candidates into a flat list so that a random - // item can be selected, weighing each queue (type/db tuple) equally. - foreach ( $pendingDBs as $type => $dbs ) { - if ( - ( is_array( $types ) && in_array( $type, $types ) ) || - ( $types === false && !in_array( $type, $wgJobTypesExcludedFromDefaultQueue ) ) - ) { - foreach ( $dbs as $db ) { - $candidates[] = array( $type, $db ); - } + $candidates = array(); // list of (type, db) + // Flatten the tree of candidates into a flat list so that a random + // item can be selected, weighing each queue (type/db tuple) equally. + foreach ( $pendingDBs as $type => $dbs ) { + if ( + ( is_array( $types ) && in_array( $type, $types ) ) || + ( $types === false && !in_array( $type, $wgJobTypesExcludedFromDefaultQueue ) ) + ) { + foreach ( $dbs as $db ) { + $candidates[] = array( $type, $db ); } } - if ( !count( $candidates ) ) { - return; // no jobs for this type - } + } + if ( !count( $candidates ) ) { + return; // no jobs for this type + } - list( $type, $db ) = $candidates[mt_rand( 0, count( $candidates ) - 1 )]; - } while ( $again ); + list( $type, $db ) = $candidates[mt_rand( 0, count( $candidates ) - 1 )]; if ( $this->hasOption( 'types' ) ) { $this->output( $db . " " . $type . "\n" ); -- 2.20.1