From 73edf3f55bf19c2581e0c1346632ea5112b473a1 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Thu, 21 Jun 2007 06:03:15 +0000 Subject: syncing up < 8 > 0 album loop bug --- lib/album.lib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/album.lib.php') diff --git a/lib/album.lib.php b/lib/album.lib.php index ef0c7124..6edfc932 100644 --- a/lib/album.lib.php +++ b/lib/album.lib.php @@ -95,14 +95,16 @@ function get_random_albums($count='') { $total = count($albums); - if ($total == '0') { return array(); } + if ($total < ($count+2)) { return array(); } for ($i=0; $i <= $count; $i++) { + $tries++; $record = rand(0,$total); - if (isset($results[$record]) || !$albums[$record]) { $i--; } + if (isset($results[$record]) || !$albums[$record]) { $i--; continue; } else { $results[$record] = $albums[$record]; } + if ($tries > 50) { return array(); } } // end for return $results; -- cgit