Closed loicbenoit closed 6 years ago
Hi,
I did not test but it seems correct.
Maybe you can simplify code but just using an array of indexes, like $taken_indexes = $index_exceptions;
and check if it used using while(in_array($currentindex, $taken_indexes)) { ... }
.
Regards
2 empty lines and 1 missing space after "while" were corrected.
Hi,
Thanks for the contribution.
Regards
Fix these error messages in log: CommonDBTM::searchOptions() in /opt/bitnami/apps/glpi/htdocs/inc/commondbtm.class.php line 3455 Duplicate key # (field A/field B) in PluginGenericobjectFoo searchOptions!
This also fixes the issue of missing fields in dropdowns for objects created with GenericObjects. For example, fields like serial where not in the list of fields to select when defining duplicity rules. It will probably fix some other issues too, because this affects anything that relies on SearchOptions, like dropdowns related to GenericObjects.
This fix can only ensure that the $options array stops repeating itself. The fix heavily relies on the provided $index_exceptions array to avoid globally reserved indexes.
The $options array repeated itself, because the "$currentindex = $index_exceptions[$field]" sometimes jumps to a lower index. The code "If this index is reserved, jump to next: $currentindex++;" was wrong in assuming that incrementing would always choose an unused index.