N°9950 - Error loading structural data on upgrade - #1019
Conversation
There was a problem hiding this comment.
Pull request overview
Allows upgrades to continue when historical structural data references a removed class.
Changes:
- Logs and skips unknown XML classes instead of throwing an exception.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (!MetaModel::IsValidClass($sClass)) { | ||
| SetupLog::Error("Unknown class - $sClass"); | ||
| throw(new Exception("Unknown class - $sClass")); | ||
| continue; // Trying to load non-existing class, ignore it |
|
| Filename | Overview |
|---|---|
| setup/xmldataloader.class.inc.php | Broadens unknown-class tolerance to every loader mode, causing non-upgrade imports to commit and report success after silently omitting invalid sections. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[XML input] --> B{Class exists?}
B -->|Yes| C[Load records]
B -->|No| D[Log and skip section]
C --> E[EndSession succeeds]
D --> E
E --> F[Commit and report success]
Reviews (1): Last reviewed commit: "N°9950 - Error loading structural data o..." | Re-trigger Greptile
| if (!MetaModel::IsValidClass($sClass)) { | ||
| SetupLog::Error("Unknown class - $sClass"); | ||
| throw(new Exception("Unknown class - $sClass")); | ||
| continue; // Trying to load non-existing class, ignore it |
There was a problem hiding this comment.
Unknown classes produce successful imports
When an administrator imports XML containing a class unavailable in the current data model, this branch records neither a loader error nor a warning, so the backoffice loader commits the valid sections and reports success while silently omitting every object in the unknown-class section.
Knowledge Base Used: Setup: Install/Upgrade Wizard
There was a problem hiding this comment.
It's Ok to continue ignoring the error. But maybe the message entry in the log should be an Info or Warning (since it does not break the setup) and the message should be more explicit, something like: "Loading of data for class '$sClass' ignored because the class does not exist."
There was a problem hiding this comment.
Good point. Error is misleading when we're intentionally continuing. Here's a suggestion using Warning (more appropriate than Info since it's still an unexpected condition worth flagging) with a clearer message:
| continue; // Trying to load non-existing class, ignore it | |
| SetupLog::Warning("Loading of data for class '$sClass' ignored because the class does not exist."); | |
| continue; // Trying to load non-existing class, ignore it |
Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Error loading structural data on upgrade when class has been removed