Skip to content

Commit f74cb22

Browse files
stonebuzzRom1-B
andauthored
Fix(Injection): fix injection for and fields (#555)
* Fix(Injection): fix injection for and fields * fix CS --------- Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com>
1 parent 80a9e94 commit f74cb22

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Fixed
1111

12+
- Fix injection for `groups_id` and `groups_id_tech` fields
1213
- Fix missing `purge` action
13-
14-
### Fixed
15-
1614
- Fix user fields nullability to prevent SQL errors during injection
1715
- Remove groups as import link field
1816
- Fix `clean` function

inc/commoninjectionlib.class.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,6 +1665,20 @@ private function effectiveAddOrUpdate($injectionClass, $item, $values, $add = tr
16651665
$toinject[$key] = $value;
16661666
}
16671667

1668+
// handle new format for group type specification
1669+
// restricting to group_item relations only
1670+
if (($key === "groups_id_tech" || $key === "groups_id") && $option['table'] == getTableForItemType(Group::class) && !empty($option) && isset($option['joinparams']['beforejoin']['table']) && $option['joinparams']['beforejoin']['table'] === getTableForItemType(Group_Item::class) && isset($option['joinparams']['beforejoin']['joinparams']['condition']['NEWTABLE.type'])) {
1671+
$value = $option['joinparams']['beforejoin']['joinparams']['condition']['NEWTABLE.type'];
1672+
// depending on the type, set the correct field (_groups_id_tech => array or _groups_id => array)
1673+
// and unset the old one (groups_id_tech => int or groups_id => int)
1674+
if ($value == Group_Item::GROUP_TYPE_TECH) {
1675+
$toinject["_groups_id_tech"] = [$value];
1676+
} else {
1677+
$toinject["_groups"] = [$value];
1678+
}
1679+
unset($toinject[$key]);
1680+
}
1681+
16681682
//keep id in case of update
16691683
if (!$add && $key === 'id') {
16701684
$toinject[$key] = $value;

0 commit comments

Comments
 (0)