[BUGFIX] Unnecessary warning in css_styled_content (division by zero)
authorThomas Layh <thomas@layh.com>
Wed, 2 May 2012 14:10:06 +0000 (16:10 +0200)
committerGeorg Ringer <mail@ringerge.org>
Thu, 3 May 2012 06:30:50 +0000 (08:30 +0200)
If tt_content.image.20.maxW is not set, PHP throws a warning about
division by zero. This is not necessary. After that the variable
$scale is not set. This patch checks if $netW is greater zero and
otherwise the else condition will set $scale to 1.

Change-Id: Icd876b33d543080e486e0184c8af34c9a3831738
Fixes: #36777
Releases: 6.0, 4.7, 4.6
Reviewed-on: http://review.typo3.org/10928
Reviewed-by: Michael Klapper
Tested-by: Michael Klapper
Reviewed-by: Philipp Gampe
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
typo3/sysext/css_styled_content/pi1/class.tx_cssstyledcontent_pi1.php

index 96cb7d3..4951b1d 100755 (executable)
@@ -692,7 +692,7 @@ class tx_cssstyledcontent_pi1 extends tslib_pibase {
                                        $accumWidth = 0; // reset accumulated net width
                                        $accumDesiredWidth = 0; // reset accumulated desired width
                                        $rowTotalMaxW = $relations_cols[$rowIdx];
-                                       if ($rowTotalMaxW > $netW)      {
+                                       if ($rowTotalMaxW > $netW && $netW > 0) {
                                                $scale = $rowTotalMaxW / $netW;
                                        } else {
                                                $scale = 1;