Skip to content

fix: pass each trigger command its own text in thold_set_environ() (#760) - #870

Merged
bmfmancini merged 1 commit into
Cacti:developfrom
bmfmancini:fix/760-trigger-cmd-environment
Nov 6, 2026
Merged

bmfmancini merged 1 commit into
Cacti:developfrom
bmfmancini:fix/760-trigger-cmd-environment

Conversation

@bmfmancini

Copy link
Copy Markdown
Member

Description

The low and normal branches of thold_command_execution() passed trigger_cmd_high to thold_set_environ(). This PR passes each branch the command it's about to run.

This changes nothing at runtime. thold_set_environ() doesn't read its $text argument; it exports the same THOLD_* variables whatever it's given. So low and normal commands already received the correct environment. The change makes the call sites say what they mean, so a future change that does use $text won't silently get the high command.

Related Issue

Fixes #760.

Motivation and Context

Correctness of the call sites; there's no user-visible behaviour change.

How Has This Been Tested?

Unit tests: TholdCommandExecutionTest's breach-direction cases already run all three branches, and the full suite passes.

Real poller: Cacti 1.2.32, PHP 8.4, cactid every 60 s, with this exact commit deployed and Enable Threshold Scripts on (restored afterwards). A live threshold was breached low and then restored. Its low and normal commands recorded their environment:

develop this PR
Low command 25 THOLD_* variables, correct THOLD_THRESHOLDNAME and THOLD_CURRENTVALUE same
Normal command 25 THOLD_* variables, correct THOLD_THRESHOLDNAME and THOLD_CURRENTVALUE same

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation repository accordingly.

…acti#760)

The low and normal branches of thold_command_execution() passed
trigger_cmd_high to thold_set_environ(). thold_set_environ() does not
currently read its $text argument (it exports the same THOLD_*
variables whatever it is given), so this changes nothing at runtime, but
each branch now passes the command it is about to run, and a future
change that does use $text will not silently get the high command.

All three branches are already exercised by TholdCommandExecutionTest's
breach-direction cases.
Copilot AI balanced review requested due to automatic review settings November 6, 2026 05:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@sonarqubecloud

sonarqubecloud Bot commented Nov 6, 2026

Copy link
Copy Markdown

@somethingwithproof somethingwithproof left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No blockers found. The full suite passes on Linux/PHP 8.4; PHP 8.2–8.4 CI is green.

@bmfmancini
bmfmancini merged commit 5e331fd into Cacti:develop Nov 6, 2026
5 checks passed
@bmfmancini
bmfmancini deleted the fix/760-trigger-cmd-environment branch November 6, 2026 22:38
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.

Bug: low/normal trigger command environments are built from trigger_cmd_high

3 participants