Skip to content

fix(ModuleInstallerAPI): Rename class in DB recursively#854

Open
Hipska wants to merge 4 commits intoCombodo:developfrom
Super-Visions:fix/moduleinstallerapi/rename_class_recursively
Open

fix(ModuleInstallerAPI): Rename class in DB recursively#854
Hipska wants to merge 4 commits intoCombodo:developfrom
Super-Visions:fix/moduleinstallerapi/rename_class_recursively

Conversation

@Hipska
Copy link
Copy Markdown
Contributor

@Hipska Hipska commented Mar 25, 2026

Base information

Question Answer
Related to a SourceForge thread / Another PR / Combodo ticket? N/A
Type of change? Bug fix

Symptom

Using ModuleInstallerAPI::RenameClassInDB to rename classes does not work for classes having intermediate classes.

Renaming Child works:

  • Parent
    • Child

Renaming Child does not work:

  • Parent
    • Intermediate
      • Child

Reproduction procedure

  1. Have an old datamodel where DB server objects are still called DBserver.
  2. ModuleInstallerAPI::RenameClassInDB('DBserver', 'DBServer'); as done in itop-config-mgmt.
  3. Run query SELECT SoftwareInstance

Observe the DB server objects not being listed (but they are counted in total objects).

Cause

The mentioned helper method only updates the finalclass field for the root class.

Proposed solution

Update the finalclass field for all parent classes recursively.

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have tested all changes I made on an iTop instance
  • I have added a unit test, otherwise I have explained why I couldn't
  • Is the PR clear and detailed enough so anyone can understand digging in the code?

@Molkobain Molkobain added the bug Something isn't working label Mar 25, 2026
@Molkobain Molkobain requested review from Copilot and rquetiez March 25, 2026 18:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes ModuleInstallerAPI::RenameClassInDB() so class renames are reflected in the DB for inheritance chains that include intermediate classes, preventing objects from “disappearing” from queries due to stale finalclass values.

Changes:

  • Replace single-root-table update with an iteration over all parent classes of the target class to update finalclass consistently across the inheritance chain.
  • Accumulate affected rows across all executed updates for logging.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread setup/moduleinstaller.class.inc.php
Comment thread setup/moduleinstaller.class.inc.php
@Hipska
Copy link
Copy Markdown
Contributor Author

Hipska commented Apr 9, 2026

Probably it could also rename the objclass on CMDBChangeOp to be able to keep history after class rename.

@jf-cbd jf-cbd moved this from First review needed to Pending review in Combodo PRs dashboard Apr 13, 2026
@Hipska
Copy link
Copy Markdown
Contributor Author

Hipska commented Apr 14, 2026

And the dest_class of SynchroReplica as well..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Pending review

Development

Successfully merging this pull request may close these issues.

5 participants