Skip to content

Fix #756: Correct malformed UPDATE SET clause in notify list delete - #794

Closed
bmfmancini wants to merge 2 commits into
Cacti:developfrom
bmfmancini:fix/issue-756-malformed-sql-notify-lists
Closed

Fix #756: Correct malformed UPDATE SET clause in notify list delete#794
bmfmancini wants to merge 2 commits into
Cacti:developfrom
bmfmancini:fix/issue-756-malformed-sql-notify-lists

Conversation

@bmfmancini

Copy link
Copy Markdown
Member

Summary

Fixes #756

In notify_lists.php, the bulk delete flow (drp_action == 1) contained a malformed SQL statement for the host email reset:

UPDATE host
SET thold_host_email = 0
AND deleted=""
WHERE ...

The AND deleted="" was incorrectly placed in the SET clause as part of the assignment expression, rather than in the WHERE clause as a filter condition.

Impact

  • The deleted="" filter was not applied as intended.
  • The expression semantics were incorrect and could silently produce unintended updates.

Fix

Moved the deleted="" filter from the SET clause to the WHERE clause, matching the structure of the adjacent thold_send_email update queries in the same function:

UPDATE host
SET thold_host_email = 0
WHERE deleted=""
AND ...

Testing

  • Verified PHP syntax with php -l notify_lists.php — no syntax errors.
  • The corrected query now matches the pattern used by the two thold_send_email updates immediately above it in the same delete path.

The host email reset query in the notify list delete action (drp_action == 1)
used 'AND deleted=""' as part of the SET clause instead of the WHERE clause,
causing the deleted filter to be ignored and potentially producing unintended
updates. Moved the deleted filter from SET to WHERE.
Copilot AI lite review requested due to automatic review settings August 17, 2026 02:53

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 reached their quota limit.

@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.

Please do not merge this form. It carries the unrelated three-line #789 change, and its host update conflicts semantically with #773's transactional notification-list deletion: #773 deliberately clears thold_host_email for soft-deleted hosts too, so restoring a host cannot resurrect a reference to a deleted list. Rebase on #773 (or choose one implementation), keep the transactional prepared-query version, add a deletion/restoration Pest case through Cacti Composer, and add the CHANGELOG entry.

@somethingwithproof

Copy link
Copy Markdown
Member

The four integration checks are using the older unpinned Cacti workflow and fail during Cacti setup before the plugin can be validated. Maintainer edits are disabled, so I cannot apply the pinned-Cacti and bounded-retry workflow fix. Please enable maintainer edits or update/rebase the branch.

@somethingwithproof

Copy link
Copy Markdown
Member

Both of these look to have landed on develop already, which is why the branch now shows a conflict.

The malformed clause order in notify_lists.php is gone. The bulk delete was rewritten to prepared statements, and deleted is now part of the WHERE rather than trailing the SET:

notify_lists.php:195  'UPDATE host SET thold_send_email = 0 WHERE thold_send_email = 2 AND deleted = "" AND thold_host_email IN (' . $placeholders . ')',

The warning branch in thold_functions.php reads the warning columns:

thold_functions.php:3472  'threshold_value' => ($warning_breach_up ? $thold_data['time_warning_hi'] : $thold_data['time_warning_low']),
thold_functions.php:3488  same
thold_functions.php:3502  same

Leaving this open rather than closing it, in case you read the current state differently. Nothing here needs rebasing if you agree it is covered.

@somethingwithproof

Copy link
Copy Markdown
Member

Closing this, following up on my comment above.

The malformed clause is fixed on develop at notify_lists.php:195-196, with deleted moved into the WHERE rather than trailing the SET. Line 197 omits it deliberately, which is what this branch conflicts against. That work landed with #773.

Issue #756 was a valid report. Reopen if you read the current develop differently.

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: notify list delete action uses malformed UPDATE SET clause for host email reset

3 participants