NagVis / nagvis

Visualization addon for your open source monitoring core
http://nagvis.org/
GNU General Public License v2.0
115 stars 73 forks source link

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

Closed schnudd31do3 closed 1 year ago

schnudd31do3 commented 1 year ago

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.