Skip to content

Commit

Permalink
bug 2970: Division by zero on batch manager
Browse files Browse the repository at this point in the history
git-svn-id: http://piwigo.org/svn/trunk@24835 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
mistic100 committed Oct 10, 2013
1 parent cfdfeb9 commit 1824570
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions admin/batch_manager.php
Expand Up @@ -490,21 +490,25 @@
;';
$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);
Expand Down Expand Up @@ -563,7 +567,7 @@
{
$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]),
);
}
}
Expand Down

0 comments on commit 1824570

Please sign in to comment.