Fix - Massive action update on CustomAssets - #1247
Open
RomainLvr wants to merge 2 commits into
Open
Conversation
Rom1-B
requested changes
Aug 20, 2026
Comment on lines
+2111
to
+2115
| } elseif (isset($_REQUEST['massiveaction'])) { // called from massiveaction | ||
| if (isset($_POST[$field['name']])) { | ||
| $data[$field['name']] = $_POST[$field['name']]; | ||
| $has_fields = true; | ||
| } |
Contributor
There was a problem hiding this comment.
Suggested change
| } elseif (isset($_REQUEST['massiveaction'])) { // called from massiveaction | |
| if (isset($_POST[$field['name']])) { | |
| $data[$field['name']] = $_POST[$field['name']]; | |
| $has_fields = true; | |
| } | |
| } elseif ( | |
| isset($_REQUEST['massiveaction']) | |
| && (isset($_POST[$field['name']]) | |
| ) { | |
| $data[$field['name']] = $_POST[$field['name']]; | |
| $has_fields = true; |
Comment on lines
+6
to
+8
| <directory name="src"/> | ||
| <file name="hook.php"/> | ||
| <file name="setup.php"/> |
Contributor
There was a problem hiding this comment.
I think we need to create a dedicated PR for PSALM to make it complete:
Suggested change
| <directory name="src"/> | |
| <file name="hook.php"/> | |
| <file name="setup.php"/> | |
| <directory name="ajax" /> | |
| <directory name="front" /> | |
| <directory name="inc" /> | |
| <directory name="src" /> | |
| <directory name="tests" /> | |
| <file name="hook.php" /> | |
| <file name="setup.php" /> |
Comment on lines
+1367
to
+1368
| // But do not escape backslashes for CustomAsset, as they are alrady escaped | ||
| if (!str_contains($search_string, 'CustomAsset')) { |
Contributor
There was a problem hiding this comment.
Suggested change
| // But do not escape backslashes for CustomAsset, as they are alrady escaped | |
| if (!str_contains($search_string, 'CustomAsset')) { | |
| // But do not escape backslashes for namespaced itemtypes, as they are already escaped | |
| if (!str_contains((string) $itemtype, '\\')) { |
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
Massive action "Update" was broken for Fields-plugin fields attached to Custom Assets:
PluginFieldsField::showSingle()looks up the field's container with aLIKEquery againstcontainers.itemtypes, but didn't escape backslashes the same wayPluginFieldsContainer::getAddSearchOptions()already does. Since CustomAsset itemtypes are namespaced classes (e.g.Glpi\CustomAsset\Transmission), the query never matched, so the field never rendered, only the "Send" button showed, and submitting produced anUndefined array keywarning.hook.phpmasked the failure.plugin_fields_MassiveActionsFieldsDisplay()ignoredshowSingle()'s return value and always returnedtrue, preventing GLPI core's fallback renderer from ever kicking in.dropdown-<Itemtype>(e.g. a multi-select of Locations) withmultipleenabled was silently emptied whenever a different field in the same container was mass-updated afterwards. The plaindropdowntype already had a guard against this (fixed in fix: multiple dropdown fields emptied when solution added #795 / fix(MassiveAction): fix incompatibility with multiple dropdowns #974), but it was missing on this sibling code path.Fix
showSingle()as ingetAddSearchOptions().hook.phpreturnshowSingle()'s actual result.dropdown-<Itemtype>multi-value branch inPluginFieldsContainer::populateData().Test plan
The test only passes if the patch Fix - Avoid array-to-string warnings on multi-value massive action fields glpi-project/glpi#25210 is applied otherwise, the error ‘Converting an array to a string’ causes the tests to fail.
Added regression tests :
MassiveActionCustomAssetTest=> field display for CustomAssets.MassiveActionMultipleDropdownTest/MassiveActionRealFlowTest=> plaindropdownmultiple field survives a sibling field's massive update.MassiveActionGlpiItemDropdownTest=>dropdown-<Itemtype>multiple field survives a sibling field's massive update (fails without the fix, passes with it).PS : i've added psalm.xml because it was missing from
make testprocess