NagVis / nagvis

Visualization addon for your open source monitoring core

Home Page:http://nagvis.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP8: Map Error: Implicit conversion from float .. to int losses precision

schnudd31do3 opened this issue · comments

When a map background has changed, it normally recreates the corresponding thumbnail. But with PHP8 the thumbnail is not generated because of an error. The error is shown as (blue icon) in the map overview and when hovering with the mouse, the error (see topic) is shown:
image

The reason is line 374 in nagvis/share/server/core/classes/CoreModOverview.php:
imagecopyresampled($thumb, $image, $thumbX, $thumbY, 0, 0, $thumbWidth, $thumbHeight, $bgWidth, $bgHeight);

The clalculaterd arguments are results of integers divided by integers. As a result they become mathematical floats.

To avoid the error, I inserted a type cast before each argument:
imagecopyresampled($thumb, $image, (int)$thumbX, (int)$thumbY, 0, 0, (int)$thumbWidth, (int)$thumbHeight, (int)$bgWidth, (int)$bgHeight);

For me, this solution solved the error.