Fix(MassiveAction): fix item2 reconciliation #19706
Merged
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
In
GLPI, if a search option references a table different from the main object, theMassiveActionclass will attempt (if the main item and the related item can be assigned to anentity) to load the related item to extract the entity (and the sub-entity if recursive) and compare it to the entity of the main item to "authorize" or deny the update.However, the loading of the related item is performed via a
getFromDB()(thus using the ID column) from the value of the modified field (=/).Thus, when the field is text, the condition on the entity is never verified and update action is authorized.
But when the field is
numeric(dropdown/number/yes no), the loading is erroneous.For example, with
YesorNo, GLPI will load sytematically the related item withID 1orID 0(which does not correspond to theIDof the line I am trying to modify via the massive actions).This is a case we have detected in the
Fieldsplugin since we added theentities_idandis_recursivecolumns.pluginsGLPI/fields#858
We have not found a similar case in GLPI (via the relation tables), primarily because there is no search option defined on a main asset for a relation table pointing to a 'numeric' field with 'allow_massiveaction => true'.
Let's take the example of a Ticket ID
14305, which has a fields field of typeYesNoand a related line indatabase concerning container table.Via the massive actions, I want to update this field.
First case: update to "No"
GLPI detects that the modified field references a different SQL table than the main item (Ticket) and the related / main item (PluginFieldsTickettickettest) can be assigned to an entity.
GLPI will then attempt to load the related item (PluginFieldsTickettickettest) with
getFromDB(value of the modified field => 0).This line does not exist in the database, the check on the entity is bypassed, and GLPI authorizes the update.
Second case: update to "Yes"
GLPI detects that the modified field references a different SQL table than the main item and that the main item (Ticket) and the related item (PluginFieldsTickettickettest) can be assigned to an entity.
GLPI will then attempt to load the related item (PluginFieldsTickettickettest) with
getFromDB(value of the modified field => 1).This line does not exist in the database, the check on the entity is performed, and GLPI refuses the update because the entity of the main item (Ticket) and the entity of the related item (PluginFieldsTickettickettest) are not the same.
@cedric-anne I am available to show you (it will certainly be more effective in person).
Screenshots (if appropriate):