Changeset 24835


Ignore:
Timestamp:
Oct 10, 2013, 1:09:51 PM (11 years ago)
Author:
mistic100
Message:

bug 2970: Division by zero on batch manager

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/batch_manager.php

    r24834 r24835  
    491491$result = pwg_query($query);
    492492
    493 if (!pwg_db_num_rows($result))
     493if (pwg_db_num_rows($result))
     494{
     495  while ($row = pwg_db_fetch_assoc($result))
     496  {
     497    if ($row['width']>0 && $row['height']>0)
     498    {
     499      $widths[] = $row['width'];
     500      $heights[] = $row['height'];
     501      $ratios[] = floor($row['width'] / $row['height'] * 100) / 100;
     502    }
     503  }
     504}
     505if (empty($widths))
    494506{ // arbitrary values, only used when no photos on the gallery
    495507  $widths = array(600, 1920, 3500);
     
    497509  $ratios = array(1.25, 1.52, 1.78);
    498510}
    499 else
    500 {
    501   while ($row = pwg_db_fetch_assoc($result))
    502   {
    503     $widths[] = $row['width'];
    504     $heights[] = $row['height'];
    505     $ratios[] = floor($row['width'] * 100 / $row['height']) / 100;
    506   }
    507 }
     511
    508512
    509513
     
    564568    $dimensions['ratio_'.$ratio_category] = array(
    565569      'min' => $ratio_categories[$ratio_category][0],
    566       'max' => $ratio_categories[$ratio_category][count($ratio_categories[$ratio_category]) - 1]
     570      'max' => array_pop($ratio_categories[$ratio_category]),
    567571      );
    568572  }
Note: See TracChangeset for help on using the changeset viewer.