Repository navigation
feat(upgrade): migrate only from 1.5; add cli/upgrade_legacy.php; move CLI scripts to cli/ (#839) - #905
Merged
Conversation
includes/database.php now migrates only from THOLD_UPGRADE_BASELINE (1.5). The 1.0.1 - 1.2.4 migrations move verbatim to the new cli/upgrade_legacy.php, which brings a 1.0 - 1.4 install to 1.5 and then runs the normal upgrade; anything before 1.0 is discarded. An older install is refused with a Cacti log error and nothing changed, and a forced upgrade re-runs the migrations from the baseline. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
3 tasks done
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical upgrade safeguards remain incomplete: forced repairs can skip required legacy migrations, and baseline refusal does not prevent installer side effects, hook activation, or file pruning.
2 open issues
What changed in this PR
Establishes Thold 1.5 as the automatic-upgrade baseline, separating legacy migrations from the Cacti plugin’s normal upgrade path.
Changes:
- Adds a legacy upgrade CLI with dry-run and debug options.
- Removes pre-baseline migrations from the normal upgrader and changes forced repairs to start at 1.5.
- Updates documentation, packaging, and baseline regression tests.
| File | Description |
|---|---|
| tests/Unit/UpgradeBaselineTest.php | Tests baseline checks and migration placement. |
| tests/Fixtures/cacti-lib/database.php | Adds a database include fixture. |
| tests/bootstrap-unit.php | Adds a version-comparison stub. |
| tests/bin/patch-coverage.php | Excludes new CLI files from coverage measurement. |
| README.md | Documents the legacy upgrade procedure. |
| manifest.json | Includes the new CLI directory. |
| includes/database.php | Enforces the baseline and retains newer migrations. |
| cli/upgrade_legacy.php | Runs legacy migrations before the standard upgrade. |
| cli/index.php | Adds a directory redirect guard. |
| CHANGELOG.md | Records the upgrade-policy changes. |
Review effort: Balanced
…839) - thold_upgrade_database() checks the recorded version before applying $force, so a forced repair (poller_thold.php forces one when a column is missing) cannot mark a legacy install current. - plugin_thold_upgrade() refuses before plugin_thold_install(true) and thold_prune_files(), and plugin_thold_install(true) refuses before registering hooks and realms, so a legacy install is left untouched until cli/upgrade_legacy.php runs. The check and its log line live in thold_upgrade_blocked_by_legacy(). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- cli_thresholds.php -> cli/thresholds.php - cli_import.php -> cli/import.php - extras/upgrade.php -> cli/upgrade.php - extras/apply_realms.php -> cli/apply_realms.php The polling scripts (poller_thold.php, thold_daemon.php, thold_process.php, thold_notify.php) stay at the plugin root. The old paths and extras/ are tombstoned in manifest.json so an upgrade removes them; the paths to include/cli_check.php are adjusted for the new depth. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
bmfmancini
approved these changes
Dec 4, 2026
This was referenced Dec 4, 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.



Closes #839
Summary
includes/database.phpnow migrates only fromTHOLD_UPGRADE_BASELINE(1.5). All gates below 1.5 are gone (0.4 through 1.2.4), so the file shrinks from 2,208 to about 960 lines. The 1.5.1, 1.5.3, 1.6, 1.8 and 1.8.3 gates and the unconditional column checks are unchanged.plugin_configrecords a version below 1.5,thold_upgrade_database()writes a Cacti log error that names the CLI and returns before touching the schema or the recorded version. A fresh install (empty version) is unaffected.forcenow means "from the baseline". The repair callers (thold.php,poller_thold.php,cli/upgrade.php) re-run every retained gate starting from 1.5, instead of from 0.1.cli/upgrade_legacy.phpNew CLI in a new
cli/folder, with the usual option parsing plusdisplay_version()anddisplay_help():--dry-run--debug,-d--version,-v,-V/--help,-h,-HFlow:
thold_setup_database(), then the 1.0.1 - 1.2.4 gates moved verbatim fromdatabase.php. It then records1.5, runsplugin_thold_install(true)(current hooks, realms, andthold_upgrade_database()from the baseline) andthold_prune_files().Other
manifest.json:cli/added toexpected;cli/index.phpis the usual directory guard.tests/bin/patch-coverage.php:cli/upgrade_legacy.phpandcli/index.phpadded to the unmeasured allowlist, alongside the other CLI entry points.README.mdupgrade note and aCHANGELOG.mdentry.Tests
UpgradeBaselineTest:thold_upgrade_needs_legacy()across fresh install, 1.0, 1.2.4, 1.4.9, 1.5 and 1.8.3.db_execute*calls and a log line naming the CLI.database.phpcontains no gate at or below 1.5.The harness gains a
cacti_version_compare()stub and an emptycacti-lib/database.phpfixture. Local run: 680 passed;validate-manifest.phpOK.Review updates (5ceb6ab)
A pre-1.5 install is refused before any side effects, and
forcecannot bypass it:thold_upgrade_database()checks the recorded version before applying$force.plugin_thold_upgrade()checks beforeplugin_thold_install(true)andthold_prune_files().plugin_thold_install(true)checks before registering hooks and realms.The shared check and its log line are
thold_upgrade_blocked_by_legacy(). The refused install keeps its recorded version, schema, hooks and files untilcli/upgrade_legacy.phpruns.CLI scripts moved into
cli/(95b847e)All non-polling command line scripts now live in
cli/, without thecli_prefix:cli_thresholds.phpcli/thresholds.phpcli_import.phpcli/import.phpextras/upgrade.phpcli/upgrade.phpextras/apply_realms.phpcli/apply_realms.phppoller_thold.php,thold_daemon.php,thold_process.php,thold_notify.php) stay at the plugin root.extras/is now empty and removed.cli_thresholds.php,cli_import.phpandextras/are tombstoned inmanifest.json, so an upgrade deletes the old copies.cli/upgrade_legacy.phpis new, so it has nothing to tombstone.cli_check.phpinclude and thechdir()paths are adjusted for the extra directory level..github/copilot-instructions.md, the coverage allowlist and the CHANGELOG are updated.