Skip to content

fix(weathermap): correct 12 rendering and config logic bugs#226

Merged
TheWitness merged 6 commits into
Cacti:developfrom
somethingwithproof:fix/weathermap-logic-bugs
May 18, 2026
Merged

fix(weathermap): correct 12 rendering and config logic bugs#226
TheWitness merged 6 commits into
Cacti:developfrom
somethingwithproof:fix/weathermap-logic-bugs

Conversation

@somethingwithproof
Copy link
Copy Markdown
Contributor

@somethingwithproof somethingwithproof commented May 17, 2026

Summary

  • Fix swapped overlibwidth/overlibheight values in asJS() and asJSON() for links and nodes
  • Fix array_merge + array_slice($newpoints, 1) for curve-point arrays: the previous union operator dropped key 0 (the previous control point needed for the next span calculation), causing malformed curves on multi-span links
  • Fix swapped preg_replace arguments in %k format handler; use preg_replace_callback with preg_quote($spec, '/') to prevent backreference expansion and dot-matches-any
  • Fix $joinchar assignment: dash flag now sets '-', not ' '
  • Fix $this->configFile$this->configfile (PHP property name case)
  • Fix legend drawing: all drawing coordinates inside $scale_im use local (0,0)-based coords; $boxx/$boxy are the map-level copy destination, not the draw origin
  • Remove dead return 0 at top of LoadCoverage() that suppressed all file I/O; add path guard and explode count check; add matching path-traversal guard to SaveCoverage()
  • Fix gdref1 hardcoded key → $scale_ref in DrawLegend_Vertical; add isset() guards on KEYTEXT[$scale_ref]
  • Fix strchr != false!== false in header injection check
  • Fix iterator variable $link_name$node_name in editor.inc.php

Test plan

  • Render a map with links that have overlibwidth/overlibheight set and verify tooltip dimensions are correct
  • Render a map with a multi-span curved link and verify no backwards segment appears
  • Render a map with a gradient scale and verify the legend box, outline, and text render at the correct legend position (not clipped to map (0,0))
  • Confirm maps with %k bandwidth formatting display correct values
  • Load and save a coverage file; verify file is read and written within the plugin base directory
  • Open editor and verify node iterator does not mix up node/link names

Copilot AI review requested due to automatic review settings May 17, 2026 09:56
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 targets several rendering, formatting, and configuration-handling bugs in the PHP Network Weathermap plugin, primarily in map serialization, legend drawing, curve calculation, and coverage loading.

Changes:

  • Corrects swapped tooltip width/height serialization for nodes and links.
  • Updates formatting, config parsing, legend rendering, and coverage-loading logic.
  • Renames an editor loop variable for node inheritance handling.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/WeatherMapNode.class.php Corrects node overlib width/height output in JS/JSON serialization.
lib/WeatherMapLink.class.php Corrects link overlib width/height output in JS/JSON serialization.
lib/WeatherMap.functions.php Updates %k/time formatting and curve point merging logic.
lib/WeatherMap.class.php Updates legend color references, config detection, cache warning text, and coverage loading.
lib/editor.inc.php Renames the node inheritance iterator variable.

Comment thread lib/WeatherMap.functions.php
Comment thread lib/WeatherMap.class.php
Comment thread lib/WeatherMap.functions.php Outdated
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…k, scale_ref isset

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…turn, chdir not dir

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…egex spec

Use (0,0) as origin for all drawing inside scale_im temp image; map
position applies only at the imagecopy destination. Drop catmull-rom
span initializer via array_slice to prevent out-of-order control point.
Escape preg_replace_callback spec with preg_quote so a decimal in the
format string does not match any character in the pattern.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Add realpath-based directory containment guard to SaveCoverage matching
the existing LoadCoverage pattern. Wrap legend title myimagestring call
in isset check for KEYTEXT scale_ref key to prevent undefined-index
notice when AllocateScaleColours omits a key for non-default scales.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@somethingwithproof somethingwithproof force-pushed the fix/weathermap-logic-bugs branch from 1d8762d to 9739e98 Compare May 17, 2026 11:34
@TheWitness TheWitness merged commit 2c7a5ae into Cacti:develop May 18, 2026
4 checks passed
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.

3 participants