diff --git a/admin.php b/admin.php
index dea47b07e..6eafcc099 100644
--- a/admin.php
+++ b/admin.php
@@ -265,26 +265,22 @@ if (in_array($page['page'], array('site_update', 'batch_manager')))
}
}
-// any orphan photo?
-$nb_orphans = count(get_orphans());
+// only calculate number of orphans on all pages if the number of images is "not huge"
+$page['nb_orphans'] = 0;
-if ($nb_orphans > 0)
+list($page['nb_photos_total']) = pwg_db_fetch_row(pwg_query('SELECT COUNT(*) FROM '.IMAGES_TABLE));
+if ($page['nb_photos_total'] < 100000) // 100k is already a big gallery
{
- $template->assign(
- array(
- 'NB_ORPHANS' => $nb_orphans,
- 'U_ORPHANS' => $link_start.'batch_manager&filter=prefilter-no_album',
- )
- );
-} else {
- $template->assign(
- array(
- 'NB_ORPHANS' => 0,
- 'U_ORPHANS' => '',
- )
- );
+ $page['nb_orphans'] = count(get_orphans());
}
+$template->assign(
+ array(
+ 'NB_ORPHANS' => $page['nb_orphans'],
+ 'U_ORPHANS' => $link_start.'batch_manager&filter=prefilter-no_album',
+ )
+ );
+
// +-----------------------------------------------------------------------+
// | Refresh permissions |
// +-----------------------------------------------------------------------+
diff --git a/admin/intro.php b/admin/intro.php
index a98d89d4b..4c7cf0d0d 100644
--- a/admin/intro.php
+++ b/admin/intro.php
@@ -54,6 +54,25 @@ if (isset($page['nb_pending_comments']))
$page['messages'][] = $message;
}
+// any orphan photo?
+$nb_orphans = $page['nb_orphans']; // already calculated in admin.php
+
+if ($page['nb_photos_total'] >= 100000) // but has not been calculated on a big gallery, so force it now
+{
+ $nb_orphans = count(get_orphans());
+}
+
+if ($nb_orphans > 0)
+{
+ $orphans_url = PHPWG_ROOT_PATH.'admin.php?page=batch_manager&filter=prefilter-no_album';
+
+ $message = '';
+ $message.= l10n('Orphans').'';
+ $message.= '';
+
+ $page['warnings'][] = $message;
+}
+
// +-----------------------------------------------------------------------+
// | template init |
// +-----------------------------------------------------------------------+