You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: finish the cleanup left in #241, #276, #306, #351 and #399 - #481
This finishes the cleanup that was still open in five issues. The rest of each issue had already landed on develop (see the comments on each issue). With this change, nothing is left in any of them.
#276: editing a MacAuth address created a duplicate row
mac_track_macauth is keyed on mac_address, and sql_save() was called with that key. Changing an entry's address therefore inserted a new row with the same mac_id instead of updating the old one. sql_save() also returned the MAC string rather than the id on updates, so the post-save redirect was wrong.
New mactrack_maca_store() updates an existing entry by mac_id, or inserts a new one, using prepared statements.
An address that another entry already authorizes is rejected with a clear message.
When an address changes, the old address's ports lose authorized unless another entry still covers them.
form_save() no longer raises the save message twice and now redirects with mac_id= (the edit page ignored id=).
The lookup keys were built with mt_mac_delim, but scanned MACs are stored as 12 hex digits with no separator. mactrack_parse_arpwatch_line() now always returns the stored form. Every other #399 item was already fixed by #400, #411, #421, #433 and #434. I rechecked them on develop.
Removed the top_header_tabs hook registration. No Cacti release calls api_plugin_hook('top_header_tabs'), and top_graph_header_tabs already draws the tab. Upgrades delete the stale plugin_hooks row.
errors_disable() / errors_restore() no longer save and restore track_errors, which PHP 8.0 removed. They still install and restore the MacTrack error handler.
Removed the $host_template_hashes / $graph_template_hashes globals from mactrack_view_graphs(). Neither is defined in Cacti or the plugin.
Deleted the empty mactrack_ajax.php. It is added to the manifest.json tombstones, removed from the realm definitions, and stripped from existing plugin_realms file lists on upgrade.
Fixed "aggergated" ? "aggregated" in the two Utilities strings, and regenerated locales/po/cacti.pot. The .po/.mo catalogs are left to Weblate's msgmerge.
locales/build_gettext.sh reads the version from INFO instead of include/cacti_version, which does not exist in a plugin. It also uses portable basename file .po and writes sed output through a temp file instead of GNU-only sed -i.
The doubled >> in the .pot bugs address was already fixed on develop.
The README now points to Plugin-Mactrack in the Cacti documentation instead of the repository wiki. Disabling the GitHub wiki is a repository setting, so it is left to a maintainer.
Not included
#465: the catalog side is already fixed on develop (39919fc / #470, plus the lv-LV and uk-UA catalogs), and every .po passes msgfmt --check --check-format. What remains is the duplicate weblate.autotranslate.autotranslate addon (id 6, mode: translate) on the Weblate component. That needs a Weblate admin, not a code change.
Testing
Full Pest suite against Cacti 1.2.x: 1178 passed, 13 skipped (database recovery tests that need MACTRACK_TEST_DSN), 0 failed.
New tests/Unit/MacAuthStoreTest.php covers:
an in-place address change
a description-only edit
a duplicate address being rejected
a new insert
editing an entry that has since been removed
MactrackUpgradeTest asserts the hook and realm cleanup on upgrade. ArpwatchParseTest was updated for the new signature.
tests/bin/patch-coverage.php: 100% of measured changed lines.
tests/bin/check-i18n-pot.php: OK.
php -l on all changed PHP files.
locales/build_gettext.sh ran end to end in a scratch copy.
- MacAuth (#276): update an entry in place when its address is edited
instead of adding a second row that reuses its mac_id; reject an address
another entry already authorizes, clear the old address's authorization,
and return to the saved entry after saving.
- ArpWatch (#399 item 7): build lookup keys in the stored MAC form so they
match scanned MACs when mt_mac_delim is set.
- PHP 8 cleanup (#351): drop the never-fired top_header_tabs hook (and its
row on upgrade), the removed track_errors ini handling, and the undefined
graph template hash globals.
- Housekeeping (#306): remove the empty mactrack_ajax.php (tombstoned, and
stripped from existing realm lists on upgrade), fix the "aggregated"
spelling, and make build_gettext.sh read the version from INFO and work
with BSD basename/sed.
- Docs (#241): point the README at the Cacti documentation instead of the
repository wiki.
Fixes#241Fixes#276Fixes#306Fixes#351Fixes#399
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Authorization updates can fail on duplicate IDs yet report success, while address changes leave stale authorization flags in aggregate and staging data.
Addresses remaining MacTrack cleanup from #241, #276, #306, #351, and #399 across authorization saving, ArpWatch matching, plugin registration, and documentation.
Changes:
Updates MacAuth entries by ID and normalizes ArpWatch lookup keys.
Removes obsolete hooks, PHP settings, globals, and the empty AJAX endpoint.
Updates documentation, gettext generation, and regression coverage.
…ables
Address review on #481:
- Upgrade gives every MAC authorization row that shares a mac_id (left by
#276) its own id, oldest row keeping the original, then makes the mac_id
key unique; new installs create it unique. Edits also match on the old
address so they cannot collide before the upgrade runs.
- mactrack_maca_store() runs in one transaction, checks every write, and
rolls back and returns 0 when any statement or the commit fails, before
any port flag is left changed.
- mactrack_maca_set_authorized() sets the flag on mac_track_ports,
mac_track_temp_ports and mac_track_aggregated_ports. Revocation skips
rows another entry still covers. Aggregated rows whose flipped twin
already exists (authorized is in the unique key) are merged into it, and
date_last is preserved.
Verified against MariaDB 10.5 with a scratch schema in addition to the unit
suite.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
MacAuth saves can silently roll back on supported MySQL installations, while index repairs may be skipped or marked complete despite failure, leaving shared IDs that can cause unintended bulk deletions.
…pair
Address the second review round on #481:
- Cacti 1.2.29's db_commit_transaction() only commits when the
MariaDB-only @@in_transaction is set, so on MySQL every MacAuth save
rolled back. Use explicit START TRANSACTION / COMMIT / ROLLBACK, as
mactrack_update_aggregated_ports() already does.
- Report a missing or non-unique mac_id key as pending upgrade work, so
installs already at this version get the repair.
- Run the repair before plugin_mactrack_install() (Cacti 1.2.x applies the
table definition to existing tables, which would try to add the unique
key over duplicate rows), and leave the version unrecorded when it fails
so the upgrade retries.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The ID repair can renumber a row between a live MacAuth save's lookup and UPDATE: upgrades hold the scan lock, but saves hold partitions. That UPDATE can match no rows yet report success, committing authorization flags for an unsaved address and returning the obsolete ID. Hold the partition lock around the entire repair, including its reads and index change, and release it in finally.
Installs already recorded at 5.1 are relaunched by the mac_id key check without a version change, so the idempotent top_header_tabs and mactrack_ajax.php realm cleanup now runs on every upgrade instead of only when the version changes. The tombstone prune stays version-gated because it also removes the dev-only tests/ tree.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Entries added after the v5.0 tag (4c9aba9) were listed under 5.0. Move them, unchanged and in order, to a new --- develop --- section so the 5.0 section matches what shipped.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… 5.1 (#465) (#482)
* fix(i18n): ASCII percent signs, restore fuzzied translations, prepare 5.1
- zh-TW, zh-CN and ja-JP used the full-width percent sign (U+FF05) in the
interface InBound/OutBound % labels and in the MAC authorization
wildcard help, which tells users to type a character the plugin does
not accept. Use the ASCII form the source string uses.
- Correcting "aggergated" in #481 made Weblate mark the two Utilities
messages fuzzy in all 42 catalogs, so they showed in English. The
existing translations are still correct; clear the flag.
- Rebuild every compiled catalog. The committed .mo files also still
carried the two retired misspelled messages.
- Release prep: rename the pending CHANGELOG section to --- 5.1 ---, fold
the unreleased documentation note into it, and update the README and
contributor instructions to 5.1 (INFO is already 5.1).
Fixes#465
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(i18n): single percent in zh labels, correct mistranslated aggregated-table messages
Address review on #482:
- Cacti unescapes %% once, so "InBound %%%" renders as "InBound %%". Use a single % in the zh-TW and zh-CN labels.
- The restored Utilities messages were machine-translated from the misspelled "aggergated" and read as "intensified", "aggravated", "aggressive" or "approaching" table in some catalogs. Use each catalog's own term for aggregated in de-DE, pt-BR, pt-PT, pl-PL, he-IL, zh-CN, tr-TR and hi-IN, and rebuild their compiled catalogs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
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.
Summary
This finishes the cleanup that was still open in five issues. The rest of each issue had already landed on
develop(see the comments on each issue). With this change, nothing is left in any of them.Fixes #241
Fixes #276
Fixes #306
Fixes #351
Fixes #399
Changes
#276: editing a MacAuth address created a duplicate row
mac_track_macauthis keyed onmac_address, andsql_save()was called with that key. Changing an entry's address therefore inserted a new row with the samemac_idinstead of updating the old one.sql_save()also returned the MAC string rather than the id on updates, so the post-save redirect was wrong.mactrack_maca_store()updates an existing entry bymac_id, or inserts a new one, using prepared statements.authorizedunless another entry still covers them.form_save()no longer raises the save message twice and now redirects withmac_id=(the edit page ignoredid=).#399 item 7: ArpWatch correlation never matched
The lookup keys were built with
mt_mac_delim, but scanned MACs are stored as 12 hex digits with no separator.mactrack_parse_arpwatch_line()now always returns the stored form. Every other #399 item was already fixed by #400, #411, #421, #433 and #434. I rechecked them ondevelop.#351: PHP 8 leftovers
top_header_tabshook registration. No Cacti release callsapi_plugin_hook('top_header_tabs'), andtop_graph_header_tabsalready draws the tab. Upgrades delete the staleplugin_hooksrow.errors_disable()/errors_restore()no longer save and restoretrack_errors, which PHP 8.0 removed. They still install and restore the MacTrack error handler.$host_template_hashes/$graph_template_hashesglobals frommactrack_view_graphs(). Neither is defined in Cacti or the plugin.#306: housekeeping
mactrack_ajax.php. It is added to themanifest.jsontombstones, removed from the realm definitions, and stripped from existingplugin_realmsfile lists on upgrade.locales/po/cacti.pot. The.po/.mocatalogs are left to Weblate's msgmerge.locales/build_gettext.shreads the version fromINFOinstead ofinclude/cacti_version, which does not exist in a plugin. It also uses portablebasename file .poand writessedoutput through a temp file instead of GNU-onlysed -i.>>in the.potbugs address was already fixed ondevelop.#241: wiki link
The README now points to Plugin-Mactrack in the Cacti documentation instead of the repository wiki. Disabling the GitHub wiki is a repository setting, so it is left to a maintainer.
Not included
#465: the catalog side is already fixed on
develop(39919fc / #470, plus the lv-LV and uk-UA catalogs), and every.popassesmsgfmt --check --check-format. What remains is the duplicateweblate.autotranslate.autotranslateaddon (id 6,mode: translate) on the Weblate component. That needs a Weblate admin, not a code change.Testing
MACTRACK_TEST_DSN), 0 failed.tests/Unit/MacAuthStoreTest.phpcovers:MactrackUpgradeTestasserts the hook and realm cleanup on upgrade.ArpwatchParseTestwas updated for the new signature.tests/bin/patch-coverage.php: 100% of measured changed lines.tests/bin/check-i18n-pot.php: OK.php -lon all changed PHP files.locales/build_gettext.shran end to end in a scratch copy.