[Fix] Purge orphaned achievement criteria progress at startup#291
Merged
billy1arm merged 1 commit intoJul 4, 2026
Merged
Conversation
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.
This was referenced Jul 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.
Paired with mangostwo/server#238 and billy1arm/MangosFour-M3#2 (same fix across the WotLK/MoP-M3 forks).
Adds a global, unconditional startup purge of orphaned
character_achievement_progressrows (criteria no longer present in DBC), mirroring the existing completed-achievement purge.Startup already drops orphaned completed achievements in
LoadCompletedAchievements()(a nonexistentachievementid is deleted for all characters). Progress rows had no equivalent: an invalidcriteriawas 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 afterLoadCompletedAchievements()(criteria/DBC stores are already loaded by then):SELECT DISTINCT criteria, validate each againstsAchievementCriteriaStore, 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 setscleaning_flagsinsaved_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