diff --git a/html/user/gallery.inc b/html/user/gallery.inc
index 1f34aa6c0e..25773655f8 100755
--- a/html/user/gallery.inc
+++ b/html/user/gallery.inc
@@ -30,16 +30,20 @@ function build_picture_pages($width, $height) {
mysql_free_result($result);
- if (count($userIds) == 0) {
- page_tail();
- exit();
+ if (count($userIds) > 0) {
+ // Randomize the ordering of users.
+ shuffle($userIds);
}
- // Randomize the ordering of users.
- shuffle($userIds);
-
$numPages = ceil(count($userIds)/($width * $height));
-
+
+ // Make sure that a page is generated even when no profiles with pictures
+ // exist in order to avoid 404 errors from the profile_menu page.
+
+ if ($numPages == 0) {
+ $numPages = 1;
+ }
+
echo "Generating $numPages pages.
";
$count = 0;