Skip to content

Commit

Permalink
Merge pull request #4275 from ampproject/fix/division-by-zero
Browse files Browse the repository at this point in the history
Fix division by zero to calculate minification ratio when original size is zero
  • Loading branch information
westonruter authored Feb 11, 2020
2 parents ea28148 + 1e8010a commit 2026afc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion includes/validation/class-amp-validated-url-post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -2168,7 +2168,11 @@ static function ( $a, $b ) use ( $stylesheets ) {
}
$origin_html .= '>';

$ratio = $stylesheet['final_size'] / $stylesheet['original_size'];
if ( 0 === $stylesheet['original_size'] ) {
$ratio = 1;
} else {
$ratio = $stylesheet['final_size'] / $stylesheet['original_size'];
}
?>
<tr class="<?php echo esc_attr( sprintf( 'stylesheet level-0 %s', 0 === $row % 2 ? 'even' : 'odd' ) ); ?>">
<td class="column-stylesheet_expand">
Expand Down

0 comments on commit 2026afc

Please sign in to comment.