Skip to content

[Fix] Purge orphaned achievement criteria progress at startup#238

Merged
billy1arm merged 1 commit into
mangostwo:masterfrom
r-log:fix/achievement-progress-startup-cleanup
Jul 4, 2026
Merged

[Fix] Purge orphaned achievement criteria progress at startup#238
billy1arm merged 1 commit into
mangostwo:masterfrom
r-log:fix/achievement-progress-startup-cleanup

Conversation

@r-log

@r-log r-log commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Paired with mangosthree/server#291 (same fix on the Cata fork).

Adds a global, unconditional startup purge of orphaned character_achievement_progress rows (criteria no longer present in DBC), mirroring the existing completed-achievement purge.

Startup already drops orphaned completed achievements in LoadCompletedAchievements() (a nonexistent achievement id is deleted for all characters). Progress rows had no equivalent: an invalid criteria was removed only lazily, per-character, when an affected character logs in (AchievementMgr::LoadFromDB). Orphaned progress rows belonging to characters that never log in therefore persisted indefinitely.

New AchievementGlobalMgr::CleanupOrphanedCriteriaProgress() runs once at startup, right after LoadCompletedAchievements() (criteria/DBC stores are already loaded by then): SELECT DISTINCT criteria, validate each against sAchievementCriteriaStore, delete invalid ones for all characters. No-op when the table is empty or nothing is orphaned; same log wording as the existing per-character purge. Code-only, no schema change.

Note (separate, not addressed here): CharacterDatabaseCleaner — which had the only other global progress purge — never runs on any core, because nothing ever sets cleaning_flags in saved_variables (schema-default 0, only ever read and reset). That's a latent design question (what should set the flags) worth its own discussion.


This change is Reviewable

Startup already removes orphaned rows from `character_achievement`
(LoadCompletedAchievements), but `character_achievement_progress` rows
whose criteria no longer exists in Achievement_Criteria.dbc were only
deleted lazily, one character at a time, when the owning character logs
in (AchievementMgr::LoadFromDB). Rows belonging to dormant characters
therefore persisted indefinitely.

Add AchievementGlobalMgr::CleanupOrphanedCriteriaProgress(), called once
at startup right after LoadCompletedAchievements, which deletes progress
rows for any criteria id no longer present in the criteria store. Same
lookup and log wording as the existing per-character purge; no-op when
nothing is orphaned.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@AppVeyorBot

Copy link
Copy Markdown

@billy1arm
billy1arm merged commit dfa4e0d into mangostwo:master Jul 4, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants