glpi
glpi copied to clipboard
Feat(Search): handle polymorphic (itemtype / items_id) criteria
Currently, GLPI can't search correctly on polymorphic linking tables.
Ex with Cable (and Agent, DatabaseInstance and other classes with searchoption field is items_id)
$tab[] = [
'id' => '10',
'table' => $this->getTable(),
'field' => 'items_id_endpoint_a',
'name' => sprintf(__('%s (%s)'), _n('Associated item', 'Associated items', 1), __('Endpoint A')),
'massiveaction' => false,
'datatype' => 'specific',
'searchtype' => 'equals',
'additionalfields' => ['itemtype_endpoint_a']
];
The SQL query generated cannot link to the itemtype column to add a left join to the related table.
This PR ttry to handle a new datatype to handle this case
- [x] Implement
itemtype/items_idsearch - [ ] Ensure that the search engine also uses the
itemtypeinput (to add a relatedwhere->itemtype = 'Computer') - [ ] Ensure that the search engine also returns the value selected in the
itemtypeinput to avoid losing selected option when the page is refreshed
| Q | A |
|---|---|
| Bug fix? | yes |
| New feature? | yes |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | yes |
| Fixed tickets | #number |