Fix PHP 8.5 compatibility issues - #248
Merged
TheWitness merged 9 commits intoSep 20, 2026
Merged
Conversation
TheWitness
requested changes
Sep 14, 2026
TheWitness
left a comment
Member
There was a problem hiding this comment.
@BridgelineTech, can you please this wrapper around imagedestroy()? Otherwise, it looks good.
if (version_compare(PHP_VERSION, '8.5.0', '<')) {
imagedestroy(blah);
}
Member
|
Copilot is recommending the use of |
Contributor
Author
|
Will do... I have a couple of additional fixes in my local for EOF and related that I have not yet submitted as PRs. I will try and get them all packaged up later, including the suggested "unset" vs just deleting. Thanks! |
xmacan
approved these changes
Sep 15, 2026
xmacan
previously approved these changes
Sep 19, 2026
imagedestroy() calls were removed for PHP 8.5 compatibility (GD images are now objects, and imagedestroy() is deprecated), but removing them outright means these temporary/intermediate images are held until PHP's own refcount garbage collection reclaims them instead of being released immediately. Replaced each removed imagedestroy() call with unset() on the same variable so the reference is dropped right away, matching the original intent.
TheWitness
self-requested a review
September 19, 2026 20:38
TheWitness
approved these changes
Sep 19, 2026
cigamit
approved these changes
Sep 20, 2026
bmfmancini
approved these changes
Sep 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes several PHP 8.5 compatibility issues encountered while running Cacti Weathermap under PHP 8.5.
The changes address runtime TypeError failures caused by stricter parameter typing in PHP/GD, along with removal of imagedestroy() calls that are deprecated in PHP 8.5 but generate non-blocking log errors.
Changes include:
Cast numeric string values before passing them to round().
Ensure GD image coordinates and dimensions are integers where required.
Store and pass TrueType font sizes as floats.
Ensure find_distance() returns an integer array index.
Guard preg_match() so integer match references are not passed as the subject.
Cast legend coordinates before calling imagecopy().
Ensure thumbnail dimensions are integers.
Remove deprecated imagedestroy() calls. GD images have been GdImage objects since PHP 8.0 and are automatically released when no longer referenced.
These issues were encountered sequentially during actual Weathermap map generation on:
Cacti 1.2.30
PHP 8.5.4
Ubuntu 26.04
After applying these changes, the Weathermap poller successfully completes map generation without PHP 8.5 compatibility warnings or fatal errors:
SYSTEM WEATHERMAP STATS: Time:0.20 Maps:1 Warnings:0 Notes:None
The two separate EOF handling fixes are intentionally not included in this PR, as they have been submitted separately.