Skip to content

Curvepoints fix causing plugin to be disabled#222

Merged
TheWitness merged 2 commits into
developfrom
curvepoints-fix
May 16, 2026
Merged

Curvepoints fix causing plugin to be disabled#222
TheWitness merged 2 commits into
developfrom
curvepoints-fix

Conversation

@TheWitness
Copy link
Copy Markdown
Member

This is an additional fix to #219 where the count function was failing due to the curvepoints variable not being a countable object, in other words, not being an array. This error would be ignored in earlier versions of PHP.

@TheWitness TheWitness merged commit 25b49ec into develop May 16, 2026
2 of 6 checks passed
@TheWitness TheWitness deleted the curvepoints-fix branch May 16, 2026 18:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a PHP 8+ compatibility issue where count() was being called on a non-countable curvepoints value, which could trigger a fatal TypeError and cause Cacti to disable the weathermap plugin during CMDPHP execution.

Changes:

  • Initialize WeatherMapLink::$curvepoints as an empty array to ensure it is always countable.
  • Replace count()/sizeof() calls with Cacti-safe helpers (cacti_count(), cacti_sizeof()) in WeatherMapLink where non-arrays could otherwise trigger fatal errors.
  • Minor formatting/cleanup in curve calculation helpers (calc_curve, calc_straight) for consistency (no behavioral change intended).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/WeatherMapLink.class.php Ensures curvepoints/vialist are handled as countable structures and uses Cacti-safe counting helpers to prevent PHP 8+ fatal errors.
lib/WeatherMap.functions.php Minor formatting/return-style cleanup in curve helper functions; no functional logic changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants