diff options
author | Andrejs Griščenko <andrejs.griscenko@zabbix.com> | 2022-06-15 16:29:50 +0300 |
---|---|---|
committer | Andrejs Griščenko <andrejs.griscenko@zabbix.com> | 2022-06-15 16:29:50 +0300 |
commit | 1797580de8187d8dcdfafaa2ed6297c4fae102db (patch) | |
tree | 3144e4908da52ecb178353ff70b5d20680d4a687 | |
parent | 1a87249790218eae15d1b38e517e4380bffbbb0f (diff) | |
parent | 999c508c4f25f8f05c69c4b1f07b9a22457d022a (diff) |
..F....... [ZBXNEXT-7722] fixed runtime errors when using Zabbix with PHP 8.1
* commit '999c508c4f25f8f05c69c4b1f07b9a22457d022a':
.......... [ZBXNEXT-7722] replaced error message in autotest
..F....... [ZBXNEXT-7722] fixed graph line being drawn with an upward offset of one pixel
..F....... [ZBXNEXT-7722] fixed runtime error "implicit conversion from float to int loses precision"
..F....... [ZBXNEXT-7722] fixed code style
..F....... [ZBXNEXT-7722] fixed runtime errors "implicit conversion from float to integer loses precision"
..F....... [ZBXNEXT-7722] fixed runtime error "implicit conversion from float to integer loses precision"
..F....... [ZBXNEXT-7722] fixed code style
..F....... [ZBXNEXT-7722] fixed code style
..F....... [ZBXNEXT-7722] fixed runtime error "implicit conversion from float to integer loses precision"
..F....... [ZBXNEXT-7722] fixed imagepolygon() and imagefilledpolygon() expect different number of parameters prior to PHP 8.1.0 and after
..F....... [ZBXNEXT-7722] fixed runtime error "implicit conversion from float to integer loses precision"
..F....... [ZBXNEXT-7722] fixed code style
..F....... [ZBXNEXT-7722] fixed runtime error "implicit conversion from float to integer loses precision"
.D........ [ZBXNEXT-7722] added changelog file
..F....... [ZBXNEXT-7722] fixed runtime errors when using Zabbix with PHP 8.1
-rw-r--r-- | ChangeLog.d/feature/ZBXNEXT-7722 | 1 | ||||
-rw-r--r-- | ui/chart4.php | 4 | ||||
-rw-r--r-- | ui/include/classes/core/ZBase.php | 6 | ||||
-rw-r--r-- | ui/include/classes/graphdraw/CGraphDraw.php | 23 | ||||
-rw-r--r-- | ui/include/classes/graphdraw/CLineGraphDraw.php | 180 | ||||
-rw-r--r-- | ui/include/classes/graphdraw/CPieGraphDraw.php | 28 | ||||
-rw-r--r-- | ui/include/classes/validators/CApiInputValidator.php | 6 | ||||
-rw-r--r-- | ui/include/draw.inc.php | 4 | ||||
-rw-r--r-- | ui/include/func.inc.php | 9 | ||||
-rw-r--r-- | ui/include/graphs.inc.php | 7 | ||||
-rw-r--r-- | ui/include/images.inc.php | 14 | ||||
-rw-r--r-- | ui/include/views/js/monitoring.sysmaps.js.php | 2 | ||||
-rw-r--r-- | ui/tests/selenium/testPageAdministrationGeneralModules.php | 2 |
13 files changed, 135 insertions, 151 deletions
diff --git a/ChangeLog.d/feature/ZBXNEXT-7722 b/ChangeLog.d/feature/ZBXNEXT-7722 new file mode 100644 index 00000000000..3851ec3fd60 --- /dev/null +++ b/ChangeLog.d/feature/ZBXNEXT-7722 @@ -0,0 +1 @@ +..F....... [ZBXNEXT-7722] fixed runtime errors when using Zabbix with PHP 8.1 (agriscenko) diff --git a/ui/chart4.php b/ui/chart4.php index f20c2367167..3c4126d029f 100644 --- a/ui/chart4.php +++ b/ui/chart4.php @@ -138,9 +138,9 @@ $maxX = 900; $minX = 0; for ($i = 1; $i <= $weeks; $i++) { - $x1 = (900 / 52) * $sizeX * ($i - 1 - $minX) / ($maxX - $minX); + $x1 = (int) ((900 / 52) * $sizeX * ($i - 1 - $minX) / ($maxX - $minX)); - $yt = $sizeY * $true[$i - 1] / 100; + $yt = (int) ($sizeY * $true[$i - 1] / 100); if ($yt > 0) { imagefilledrectangle($im, $x1 + $shiftX, $shiftYup, $x1 + $shiftX + 8, $yt + $shiftYup, imagecolorallocate($im, 235, 120, 120)); // red } diff --git a/ui/include/classes/core/ZBase.php b/ui/include/classes/core/ZBase.php index 57aecf30828..6c3afe84c07 100644 --- a/ui/include/classes/core/ZBase.php +++ b/ui/include/classes/core/ZBase.php @@ -490,7 +490,11 @@ class ZBase { $action_class = $router->getController(); try { - if (!class_exists($action_class, true)) { + if ($action_class === null) { + throw new Exception(_('Class not found.')); + } + + if (!class_exists($action_class)) { throw new Exception(_s('Class %1$s not found for action %2$s.', $action_class, $action_name)); } diff --git a/ui/include/classes/graphdraw/CGraphDraw.php b/ui/include/classes/graphdraw/CGraphDraw.php index ef42dff9f57..52107270fdd 100644 --- a/ui/include/classes/graphdraw/CGraphDraw.php +++ b/ui/include/classes/graphdraw/CGraphDraw.php @@ -124,13 +124,9 @@ abstract class CGraphDraw { // i should rename no alpha to alpha at some point to get rid of some confusion foreach ($this->colorsrgb as $name => $RGBA) { - if (isset($RGBA[3]) && function_exists('imagecolorexactalpha') - && function_exists('imagecreatetruecolor') && @imagecreatetruecolor(1, 1)) { - $this->colors[$name] = imagecolorexactalpha($this->im, $RGBA[0], $RGBA[1], $RGBA[2], $RGBA[3]); - } - else { - $this->colors[$name] = imagecolorallocate($this->im, $RGBA[0], $RGBA[1], $RGBA[2]); - } + $this->colors[$name] = array_key_exists(3, $RGBA) + ? imagecolorexactalpha($this->im, $RGBA[0], $RGBA[1], $RGBA[2], $RGBA[3]) + : imagecolorallocate($this->im, $RGBA[0], $RGBA[1], $RGBA[2]); } } @@ -259,7 +255,7 @@ abstract class CGraphDraw { return get_color($this->im, $color, $alfa); } - public function getShadow($color, $alfa = 0) { + public function getShadow($color, $alpha = 0) { if (isset($this->colorsrgb[$color])) { $red = $this->colorsrgb[$color][0]; $green = $this->colorsrgb[$color][1]; @@ -270,16 +266,15 @@ abstract class CGraphDraw { } if ($this->sum > 0) { - $red = (int)($red * 0.6); - $green = (int)($green * 0.6); - $blue = (int)($blue * 0.6); + $red = (int) ($red * 0.6); + $green = (int) ($green * 0.6); + $blue = (int) ($blue * 0.6); } $RGB = [$red, $green, $blue]; - if (isset($alfa) && function_exists('imagecolorexactalpha') && function_exists('imagecreatetruecolor') - && @imagecreatetruecolor(1, 1)) { - return imagecolorexactalpha($this->im, $RGB[0], $RGB[1], $RGB[2], $alfa); + if ($alpha != 0) { + return imagecolorexactalpha($this->im, $RGB[0], $RGB[1], $RGB[2], $alpha); } return imagecolorallocate($this->im, $RGB[0], $RGB[1], $RGB[2]); diff --git a/ui/include/classes/graphdraw/CLineGraphDraw.php b/ui/include/classes/graphdraw/CLineGraphDraw.php index 4b9df8f15b5..a4988b1e782 100644 --- a/ui/include/classes/graphdraw/CLineGraphDraw.php +++ b/ui/include/classes/graphdraw/CLineGraphDraw.php @@ -722,16 +722,17 @@ class CLineGraphDraw extends CGraphDraw { $gbColor ); - imagefilledpolygon( - $this->im, - [ - $this->shiftXleft + $this->shiftXCaption - 3, $this->shiftY - 5, - $this->shiftXleft + $this->shiftXCaption + 3, $this->shiftY - 5, - $this->shiftXleft + $this->shiftXCaption, $this->shiftY - 10 - ], - 3, - $this->getColor('White') - ); + $points = [ + $this->shiftXleft + $this->shiftXCaption - 3, $this->shiftY - 5, + $this->shiftXleft + $this->shiftXCaption + 3, $this->shiftY - 5, + $this->shiftXleft + $this->shiftXCaption, $this->shiftY - 10 + ]; + if (PHP_VERSION_ID >= 80100) { + imagefilledpolygon($this->im, $points, $this->getColor('White')); + } + else { + imagefilledpolygon($this->im, $points, 3, $this->getColor('White')); + } /* draw left axis triangle */ zbx_imageline($this->im, $this->shiftXleft + $this->shiftXCaption - 3, $this->shiftY - 5, @@ -765,16 +766,17 @@ class CLineGraphDraw extends CGraphDraw { $gbColor ); - imagefilledpolygon( - $this->im, - [ - $this->sizeX + $this->shiftXleft + $this->shiftXCaption - 3, $this->shiftY - 5, - $this->sizeX + $this->shiftXleft + $this->shiftXCaption + 3, $this->shiftY - 5, - $this->sizeX + $this->shiftXleft + $this->shiftXCaption, $this->shiftY - 10 - ], - 3, - $this->getColor('White') - ); + $points = [ + $this->sizeX + $this->shiftXleft + $this->shiftXCaption - 3, $this->shiftY - 5, + $this->sizeX + $this->shiftXleft + $this->shiftXCaption + 3, $this->shiftY - 5, + $this->sizeX + $this->shiftXleft + $this->shiftXCaption, $this->shiftY - 10 + ]; + if (PHP_VERSION_ID >= 80100) { + imagefilledpolygon($this->im, $points, $this->getColor('White')); + } + else { + imagefilledpolygon($this->im, $points, 3, $this->getColor('White')); + } /* draw right axis triangle */ zbx_imageline($this->im, $this->sizeX + $this->shiftXleft + $this->shiftXCaption - 3, $this->shiftY - 5, @@ -807,16 +809,17 @@ class CLineGraphDraw extends CGraphDraw { $gbColor ); - imagefilledpolygon( - $this->im, - [ - $this->sizeX + $this->shiftXleft + $this->shiftXCaption + 5, $this->sizeY + $this->shiftY - 2, - $this->sizeX + $this->shiftXleft + $this->shiftXCaption + 5, $this->sizeY + $this->shiftY + 4, - $this->sizeX + $this->shiftXleft + $this->shiftXCaption + 10, $this->sizeY + $this->shiftY + 1 - ], - 3, - $this->getColor('White') - ); + $points = [ + $this->sizeX + $this->shiftXleft + $this->shiftXCaption + 5, $this->sizeY + $this->shiftY - 2, + $this->sizeX + $this->shiftXleft + $this->shiftXCaption + 5, $this->sizeY + $this->shiftY + 4, + $this->sizeX + $this->shiftXleft + $this->shiftXCaption + 10, $this->sizeY + $this->shiftY + 1 + ]; + if (PHP_VERSION_ID >= 80100) { + imagefilledpolygon($this->im, $points, $this->getColor('White')); + } + else { + imagefilledpolygon($this->im, $points, 3, $this->getColor('White')); + } /* draw X axis triangle */ zbx_imageline($this->im, $this->sizeX + $this->shiftXleft + $this->shiftXCaption + 5, $this->sizeY + $this->shiftY - 2, @@ -1392,13 +1395,7 @@ class CLineGraphDraw extends CGraphDraw { } // draw color square - if (function_exists('imagecolorexactalpha') && function_exists('imagecreatetruecolor') && @imagecreatetruecolor(1, 1)) { - $colorSquare = imagecreatetruecolor(11, 11); - } - else { - $colorSquare = imagecreate(11, 11); - } - + $colorSquare = imagecreatetruecolor(11, 11); imagefill($colorSquare, 0, 0, $this->getColor($this->graphtheme['backgroundcolor'], 0)); imagefilledrectangle($colorSquare, 0, 0, 10, 10, $color); imagerectangle($colorSquare, 0, 0, 10, 10, $this->getColor('Black')); @@ -1512,27 +1509,30 @@ class CLineGraphDraw extends CGraphDraw { ? $this->graphtheme['leftpercentilecolor'] : $this->graphtheme['rightpercentilecolor']; - imagefilledpolygon( - $this->im, - [ - $leftXShift + 5, $this->sizeY + $this->shiftY + 14 * $rowNum + self::LEGEND_OFFSET_Y, - $leftXShift - 5, $this->sizeY + $this->shiftY + 14 * $rowNum + self::LEGEND_OFFSET_Y, - $leftXShift, $this->sizeY + $this->shiftY + 14 * $rowNum + self::LEGEND_OFFSET_Y - 10 - ], - 3, - $this->getColor($color) - ); + $points = [ + $leftXShift + 5, $this->sizeY + $this->shiftY + 14 * $rowNum + self::LEGEND_OFFSET_Y, + $leftXShift - 5, $this->sizeY + $this->shiftY + 14 * $rowNum + self::LEGEND_OFFSET_Y, + $leftXShift, $this->sizeY + $this->shiftY + 14 * $rowNum + self::LEGEND_OFFSET_Y - 10 + ]; + if (PHP_VERSION_ID >= 80100) { + imagefilledpolygon($this->im, $points, $this->getColor($color)); + } + else { + imagefilledpolygon($this->im, $points, 3, $this->getColor($color)); + } + + $points = [ + $leftXShift + 5, $this->sizeY + $this->shiftY + 14 * $rowNum + self::LEGEND_OFFSET_Y, + $leftXShift - 5, $this->sizeY + $this->shiftY + 14 * $rowNum + self::LEGEND_OFFSET_Y, + $leftXShift, $this->sizeY + $this->shiftY + 14 * $rowNum + self::LEGEND_OFFSET_Y - 10 + ]; + if (PHP_VERSION_ID >= 80100) { + imagepolygon($this->im, $points, $this->getColor('Black No Alpha')); + } + else { + imagepolygon($this->im, $points, 3, $this->getColor('Black No Alpha')); + } - imagepolygon( - $this->im, - [ - $leftXShift + 5, $this->sizeY + $this->shiftY + 14 * $rowNum + self::LEGEND_OFFSET_Y, - $leftXShift - 5, $this->sizeY + $this->shiftY + 14 * $rowNum + self::LEGEND_OFFSET_Y, - $leftXShift, $this->sizeY + $this->shiftY + 14 * $rowNum + self::LEGEND_OFFSET_Y - 10 - ], - 3, - $this->getColor('Black No Alpha') - ); $rowNum++; } } @@ -1647,14 +1647,14 @@ class CLineGraphDraw extends CGraphDraw { $x1 = $from + $this->shiftXleft - 1; $x2 = $to + $this->shiftXleft; - $y1min = $zero - ($min_from - $oxy) / $unit2px; - $y2min = $zero - ($min_to - $oxy) / $unit2px; + $y1min = (int) round($zero - ($min_from - $oxy) / $unit2px); + $y2min = (int) round($zero - ($min_to - $oxy) / $unit2px); - $y1max = $zero - ($max_from - $oxy) / $unit2px; - $y2max = $zero - ($max_to - $oxy) / $unit2px; + $y1max = (int) round($zero - ($max_from - $oxy) / $unit2px); + $y2max = (int) round($zero - ($max_to - $oxy) / $unit2px); - $y1avg = $zero - ($avg_from - $oxy) / $unit2px; - $y2avg = $zero - ($avg_to - $oxy) / $unit2px; + $y1avg = (int) round($zero - ($avg_from - $oxy) / $unit2px); + $y2avg = (int) round($zero - ($avg_to - $oxy) / $unit2px); switch ($calc_fnc) { case CALC_FNC_MAX: @@ -1734,7 +1734,13 @@ class CLineGraphDraw extends CGraphDraw { $style = $drawtype == GRAPH_ITEM_DRAWTYPE_BOLD_LINE ? LINE_TYPE_BOLD : LINE_TYPE_NORMAL; if ($calc_fnc == CALC_FNC_ALL) { - imagefilledpolygon($this->im, $a, 4, $minmax_color); + if (PHP_VERSION_ID >= 80100) { + imagefilledpolygon($this->im, $a, $avg_color); + } + else { + imagefilledpolygon($this->im, $a, 4, $minmax_color); + } + if (!$y1x || !$y2x) { zbx_imagealine($this->im, $x1, $y1max, $x2, $y2max, $max_color, $style); } @@ -1755,15 +1761,8 @@ class CLineGraphDraw extends CGraphDraw { break; case GRAPH_ITEM_DRAWTYPE_DASHED_LINE: - if (function_exists('imagesetstyle')) { - // use imagesetstyle+imageline instead of bugged imagedashedline - $style = [$avg_color, $avg_color, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT]; - imagesetstyle($this->im, $style); - zbx_imageline($this->im, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED); - } - else { - imagedashedline($this->im, $x1, $y1, $x2, $y2, $avg_color); - } + imagesetstyle($this->im, [$avg_color, $avg_color, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT]); + zbx_imageline($this->im, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED); break; case GRAPH_ITEM_DRAWTYPE_GRADIENT_LINE: @@ -1784,7 +1783,12 @@ class CLineGraphDraw extends CGraphDraw { $a[6] = $x2; $a[7] = $y2; - imagefilledpolygon($this->im, $a, 4, $avg_color); + if (PHP_VERSION_ID >= 80100) { + imagefilledpolygon($this->im, $a, $avg_color); + } + else { + imagefilledpolygon($this->im, $a, 4, $avg_color); + } } else { imageLine($this->im, $x1, $y1, $x2, $y2, $avg_color); // draw the initial line @@ -1817,15 +1821,12 @@ class CLineGraphDraw extends CGraphDraw { $steps = $this->sizeY + $this->shiftY - $gy + 1; for ($j = 0; $j < $steps; $j++) { - if (($gy + $j) < ($this->shiftY + $startAlpha)) { - $alpha = 0; - } - else { - $alpha = 127 - abs(127 - ($alphaRatio * ($gy + $j - $this->shiftY - $startAlpha))); - } + $alpha = ($gy + $j) < ($this->shiftY + $startAlpha) + ? 0 + : 127 - (int) abs(127 - ($alphaRatio * ($gy + $j - $this->shiftY - $startAlpha))); $color = imagecolorexactalpha($this->im, $red, $green, $blue, $alpha); - imagesetpixel($this->im, $x2 + $i, $gy + $j, $color); + imagesetpixel($this->im, $x2 + $i, (int) $gy + $j, $color); } } } @@ -2040,14 +2041,7 @@ class CLineGraphDraw extends CGraphDraw { $this->selectTriggers(); $this->calcDimensions(); - if (function_exists('imagecolorexactalpha') && function_exists('imagecreatetruecolor') - && @imagecreatetruecolor(1, 1) - ) { - $this->im = imagecreatetruecolor(1, 1); - } - else { - $this->im = imagecreate(1, 1); - } + $this->im = imagecreatetruecolor(1, 1); $this->initColors(); @@ -2077,13 +2071,7 @@ class CLineGraphDraw extends CGraphDraw { $this->calcPercentile(); $this->calcZero(); - if (function_exists('imagecolorexactalpha') && function_exists('imagecreatetruecolor') - && @imagecreatetruecolor(1, 1)) { - $this->im = imagecreatetruecolor($this->fullSizeX, $this->fullSizeY); - } - else { - $this->im = imagecreate($this->fullSizeX, $this->fullSizeY); - } + $this->im = imagecreatetruecolor($this->fullSizeX, $this->fullSizeY); $this->initColors(); $this->drawRectangle(); diff --git a/ui/include/classes/graphdraw/CPieGraphDraw.php b/ui/include/classes/graphdraw/CPieGraphDraw.php index ab7557d9bf1..c69ad86fc4c 100644 --- a/ui/include/classes/graphdraw/CPieGraphDraw.php +++ b/ui/include/classes/graphdraw/CPieGraphDraw.php @@ -86,22 +86,24 @@ class CPieGraphDraw extends CGraphDraw { $count *= $this->exploderad; $anglemid = (int) (($anglestart + $angleend) / 2); - $y+= round($count * sin(deg2rad($anglemid))); - $x+= round($count * cos(deg2rad($anglemid))); + $y += round($count * sin(deg2rad($anglemid))); + $x += round($count * cos(deg2rad($anglemid))); - return [$x, $y]; + return [(int) $x, (int) $y]; } protected function calcExplodedRadius($sizeX, $sizeY, $count) { $count *= $this->exploderad * 2; $sizeX -= $count; $sizeY -= $count; - return [$sizeX, $sizeY]; + + return [(int) $sizeX, (int) $sizeY]; } protected function calc3DAngle($sizeX, $sizeY) { $sizeY *= GRAPH_3D_ANGLE / 90; - return [$sizeX, round($sizeY)]; + + return [$sizeX, (int) round($sizeY)]; } protected function selectData() { @@ -432,8 +434,8 @@ class CPieGraphDraw extends CGraphDraw { list($sizeX, $sizeY) = $this->calcExplodedRadius($sizeX, $sizeY, count($values)); } - $xc = $x = (int) $this->sizeX / 2 + $this->shiftXleft; - $yc = $y = (int) $this->sizeY / 2 + $this->shiftY; + $xc = $x = (int) ($this->sizeX / 2) + $this->shiftXleft; + $yc = $y = (int) ($this->sizeY / 2) + $this->shiftY; $anglestart = 0; $angleend = 0; @@ -513,8 +515,8 @@ class CPieGraphDraw extends CGraphDraw { list($sizeX, $sizeY) = $this->calc3DAngle($sizeX, $sizeY); - $xc = $x = (int) $this->sizeX / 2 + $this->shiftXleft; - $yc = $y = (int) $this->sizeY / 2 + $this->shiftY; + $xc = $x = (int) ($this->sizeX / 2) + $this->shiftXleft; + $yc = $y = (int) ($this->sizeY / 2) + $this->shiftY; // bottom angle line $anglestart = 0; @@ -701,12 +703,8 @@ class CPieGraphDraw extends CGraphDraw { $this->exploderad = (int) $this->sizeX / 100; $this->exploderad3d = (int) $this->sizeX / 60; - if (function_exists('ImageColorExactAlpha') && function_exists('ImageCreateTrueColor') && @imagecreatetruecolor(1, 1)) { - $this->im = imagecreatetruecolor($this->fullSizeX, $this->fullSizeY); - } - else { - $this->im = imagecreate($this->fullSizeX, $this->fullSizeY); - } + $this->im = imagecreatetruecolor($this->fullSizeX, $this->fullSizeY); + $this->initColors(); $this->drawRectangle(); $this->drawHeader(); diff --git a/ui/include/classes/validators/CApiInputValidator.php b/ui/include/classes/validators/CApiInputValidator.php index 17827dcce9b..ab69f47c5a3 100644 --- a/ui/include/classes/validators/CApiInputValidator.php +++ b/ui/include/classes/validators/CApiInputValidator.php @@ -2554,14 +2554,14 @@ class CApiInputValidator { return true; } - [$year, $month, $day] = sscanf($data, '%d-%d-%d'); + $date = DateTime::createFromFormat(ZBX_DATE, $data); - if (!checkdate($month, $day, $year)) { + if (!$date || $date->format(ZBX_DATE) !== $data) { $error = _s('Invalid parameter "%1$s": %2$s.', $path, _('a date in YYYY-MM-DD format is expected')); return false; } - if (!validateDateInterval($year, $month, $day)) { + if (!validateDateInterval($date->format('Y'), $date->format('m'), $date->format('d'))) { $error = _s('Invalid parameter "%1$s": %2$s.', $path, _s('value must be between "%1$s" and "%2$s"', '1970-01-01', '2038-01-18') ); diff --git a/ui/include/draw.inc.php b/ui/include/draw.inc.php index 2fb972d71a7..2590dcfe664 100644 --- a/ui/include/draw.inc.php +++ b/ui/include/draw.inc.php @@ -27,14 +27,14 @@ * @param array $fgColor foreground color, array of RGB * @param float $alpha transparency index in range of 0-1, 1 returns unchanged fgColor color * - * @return array new color + * @return int A color index. */ function zbx_colormix($image, $bgColor, $fgColor, $alpha) { $r = $bgColor[0] + ($fgColor[0] - $bgColor[0]) * $alpha; $g = $bgColor[1] + ($fgColor[1] - $bgColor[1]) * $alpha; $b = $bgColor[2] + ($fgColor[2] - $bgColor[2]) * $alpha; - return imagecolorresolvealpha($image, $r, $g, $b, 0); + return imagecolorresolvealpha($image, (int) $r, (int) $g, (int) $b, 0); } /** diff --git a/ui/include/func.inc.php b/ui/include/func.inc.php index 25289064bd1..99176b386fe 100644 --- a/ui/include/func.inc.php +++ b/ui/include/func.inc.php @@ -2231,19 +2231,14 @@ function splitPath($path) { * @param string $color a hexadecimal color identifier like "1F2C33" * @param int $alpha * - * @return int|false + * @return int */ function get_color($image, $color, $alpha = 0) { $red = hexdec('0x'.substr($color, 0, 2)); $green = hexdec('0x'.substr($color, 2, 2)); $blue = hexdec('0x'.substr($color, 4, 2)); - if (function_exists('imagecolorexactalpha') && function_exists('imagecreatetruecolor') - && @imagecreatetruecolor(1, 1)) { - return imagecolorexactalpha($image, $red, $green, $blue, $alpha); - } - - return imagecolorallocate($image, $red, $green, $blue); + return imagecolorexactalpha($image, $red, $green, $blue, $alpha); } /** diff --git a/ui/include/graphs.inc.php b/ui/include/graphs.inc.php index 987f4981eec..dec27508bb7 100644 --- a/ui/include/graphs.inc.php +++ b/ui/include/graphs.inc.php @@ -532,12 +532,15 @@ function get_next_color($palettetype = 0) { * @param resource $image * @param int $fontsize * @param int $angle - * @param int $x - * @param int $y + * @param int|float $x + * @param int|float $y * @param int $color a numeric color identifier from imagecolorallocate() or imagecolorallocatealpha() * @param string $string */ function imageText($image, $fontsize, $angle, $x, $y, $color, $string) { + $x = (int) $x; + $y = (int) $y; + if ((preg_match(ZBX_PREG_DEF_FONT_STRING, $string) && $angle != 0) || ZBX_FONT_NAME == ZBX_GRAPH_FONT_NAME) { $ttf = ZBX_FONTPATH.'/'.ZBX_FONT_NAME.'.ttf'; imagettftext($image, $fontsize, $angle, $x, $y, $color, $ttf, $string); diff --git a/ui/include/images.inc.php b/ui/include/images.inc.php index 6dcb93c5306..599c92d8e5c 100644 --- a/ui/include/images.inc.php +++ b/ui/include/images.inc.php @@ -75,12 +75,10 @@ function imageThumb($source, $thumbWidth = 0, $thumbHeight = 0) { } } - if (function_exists('imagecreatetruecolor') && @imagecreatetruecolor(1, 1)) { - $thumb = imagecreatetruecolor($thumbWidth, $thumbHeight); - } - else { - $thumb = imagecreate($thumbWidth, $thumbHeight); - } + $thumbWidth = (int) round($thumbWidth); + $thumbHeight = (int) round($thumbHeight); + + $thumb = imagecreatetruecolor($thumbWidth, $thumbHeight); // preserve png transparency imagealphablending($thumb, false); @@ -91,11 +89,13 @@ function imageThumb($source, $thumbWidth = 0, $thumbHeight = 0) { 0, 0, 0, 0, $thumbWidth, $thumbHeight, - $srcWidth, $srcHeight); + $srcWidth, $srcHeight + ); imagedestroy($source); $source = $thumb; } + return $source; } diff --git a/ui/include/views/js/monitoring.sysmaps.js.php b/ui/include/views/js/monitoring.sysmaps.js.php index f929a4cc364..00712c93eb2 100644 --- a/ui/include/views/js/monitoring.sysmaps.js.php +++ b/ui/include/views/js/monitoring.sysmaps.js.php @@ -127,7 +127,7 @@ function createFontSelect(string $name): CSelect { ->setId('areaSizeHeight') ], 'areaSizeRow') ->addRow(_('Placing algorithm'), - (new CRadioButtonList(null, SYSMAP_ELEMENT_AREA_VIEWTYPE_GRID)) + (new CRadioButtonList('viewtype', SYSMAP_ELEMENT_AREA_VIEWTYPE_GRID)) ->addValue(_('Grid'), SYSMAP_ELEMENT_AREA_VIEWTYPE_GRID) ->setModern(true), 'areaPlacingRow' diff --git a/ui/tests/selenium/testPageAdministrationGeneralModules.php b/ui/tests/selenium/testPageAdministrationGeneralModules.php index e81b8a32477..fd504126a4e 100644 --- a/ui/tests/selenium/testPageAdministrationGeneralModules.php +++ b/ui/tests/selenium/testPageAdministrationGeneralModules.php @@ -582,7 +582,7 @@ class testPageAdministrationGeneralModules extends CWebTest { if (CTestArrayHelper::get($entry, 'check_disabled', true)) { $this->page->open('zabbix.php?action='.$entry['action'])->waitUntilReady(); $message = CMessageElement::find()->one(); - $this->assertStringContainsString('Class not found for action '.$entry['action'], $message->getText()); + $this->assertStringContainsString('Class not found', $message->getText()); $this->page->open('zabbix.php?action=module.list'); } } |