Fix incorrect declaration during order deletion#580
Open
stonebuzz wants to merge 2 commits into
Open
Conversation
2 tasks
Rom1-B
approved these changes
May 18, 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.
Checklist before requesting a review
Please delete options that are not relevant.
Description
When deleting an order, GLPI was logging the following warnings:
Three separate issues were identified:
1. Incorrect Parent/Child Relationship Direction
The previous relation declarations incorrectly defined
glpi_plugin_order_ordersas the parent table and the dropdown tables (orderpayments,ordertaxes,ordertypes,orderstates) as child tables.Additionally, the relations referenced a non-existent field (
plugin_order_orders_id) in these dropdown tables.The correct relationship direction is the opposite:
Dropdown tables are the parent entities.
glpi_plugin_order_ordersis the child table through foreign keys such as:plugin_order_orderpayments_idplugin_order_ordertaxes_idplugin_order_ordertypes_idplugin_order_orderstates_id2. Case Mismatch During Initial Class Resolution
GLPI core method
getItemTypeForTable()returns a lowercase-computed class name (PluginOrderOrderpayment) during the first resolution, then returns the correctly cached class name (PluginOrderOrderPayment) on subsequent calls.Inside
getDbRelations(), GLPI validates these values using a strict comparison (!==), which causes the validation to fail if the plugin classes have not yet been loaded at the time the method is executed.As a result, relation validation failed during the initial lookup phase.
3. Missing
glpi_Table PrefixThe
analyticnaturestable was incorrectly declared as:instead of the correct table name:
Solution
The issue was resolved through the following changes:
Refactored
plugin_order_getDatabaseRelations()to declare all relations using the correct parent → child direction.Added
include_oncestatements for allinc/*.phpfiles at the beginning of the function to ensure that all plugin classes are loaded before GLPI attempts class resolution, preventing case mismatch issues.Corrected the table declaration:
plugin_order_analyticnaturesglpi_plugin_order_analyticnatures