aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2013-10-10 11:09:51 +0000
committermistic100 <mistic@piwigo.org>2013-10-10 11:09:51 +0000
commit18245703686f566b3e044a6ba1a643f0d43a4a7d (patch)
tree3f38acd8b456f6b1df3c4b088c4087607efe6c05 /admin
parentcfdfeb989d3a801e8131128bb2e4b53817278be5 (diff)
bug 2970: Division by zero on batch manager
git-svn-id: http://piwigo.org/svn/trunk@24835 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/batch_manager.php26
1 files changed, 15 insertions, 11 deletions
diff --git a/admin/batch_manager.php b/admin/batch_manager.php
index 89fac392d..75e20917f 100644
--- a/admin/batch_manager.php
+++ b/admin/batch_manager.php
@@ -490,21 +490,25 @@ SELECT
;';
$result = pwg_query($query);
-if (!pwg_db_num_rows($result))
-{ // arbitrary values, only used when no photos on the gallery
- $widths = array(600, 1920, 3500);
- $heights = array(480, 1080, 2300);
- $ratios = array(1.25, 1.52, 1.78);
-}
-else
+if (pwg_db_num_rows($result))
{
while ($row = pwg_db_fetch_assoc($result))
{
- $widths[] = $row['width'];
- $heights[] = $row['height'];
- $ratios[] = floor($row['width'] * 100 / $row['height']) / 100;
+ if ($row['width']>0 && $row['height']>0)
+ {
+ $widths[] = $row['width'];
+ $heights[] = $row['height'];
+ $ratios[] = floor($row['width'] / $row['height'] * 100) / 100;
+ }
}
}
+if (empty($widths))
+{ // arbitrary values, only used when no photos on the gallery
+ $widths = array(600, 1920, 3500);
+ $heights = array(480, 1080, 2300);
+ $ratios = array(1.25, 1.52, 1.78);
+}
+
$widths = array_unique($widths);
@@ -563,7 +567,7 @@ foreach (array_keys($ratio_categories) as $ratio_category)
{
$dimensions['ratio_'.$ratio_category] = array(
'min' => $ratio_categories[$ratio_category][0],
- 'max' => $ratio_categories[$ratio_category][count($ratio_categories[$ratio_category]) - 1]
+ 'max' => array_pop($ratio_categories[$ratio_category]),
);
}
}