Repository navigation
fix: remove trailing comma in device edit SNMP settings UPDATE - #397
Merged
Merged
Conversation
The UPDATE mac_track_devices statement ended its SET list with a comma before WHERE, causing an SQL syntax error whenever the device edit page auto-corrected the SNMP settings. Adds a regression test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The narrow correction resolves the SQL error, and the regression assertions detect the original defect.
0 open findings
What changed in this PR
Fixes the SQL syntax error when the device edit page saves auto-corrected SNMP settings.
Changes:
- Removes the trailing comma before
WHERE. - Adds a regression test and changelog entry.
| File | Description |
|---|---|
| tests/Unit/DeviceEditSnmpUpdateSqlTest.php | Checks for trailing commas before WHERE. |
| mactrack_devices.php | Corrects the SNMP settings UPDATE syntax. |
| CHANGELOG.md | Documents the fix. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
xmacan
previously approved these changes
Oct 16, 2026
xmacan
approved these changes
Oct 16, 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.
Fixes a SQL syntax error in the device edit page.
The
UPDATE mac_track_devicesthat persists auto-corrected SNMP settings ended itsSETlist withsnmp_context = ?,immediately beforeWHERE, which MariaDB/MySQL reject. Seen in the Cacti log asSQL Backtrace: mactrack_devices.php[54]:mactrack_device_edit() -> db_execute_prepared().Changes:
Note: the related
Undefined array keywarnings inbuild_InterfacesTable()(v4.8, mactrack_functions.php:743) are already guarded byisset()ondevelop.