Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicated search option key bug #214

Merged
merged 1 commit into from
Sep 7, 2018

Conversation

loicbenoit
Copy link
Contributor

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.

@cedric-anne
Copy link
Contributor

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

@loicbenoit
Copy link
Contributor Author

2 empty lines and 1 missing space after "while" were corrected.

@cedric-anne cedric-anne changed the base branch from master to develop September 6, 2018 13:22
1. Fixes errors : "Duplicate key # (field A/field B) in
PluginGenericobjectFoo searchOptions!"
2. Fixes missing fields in dropdowns for objects created with
GenericObjects.
@cedric-anne cedric-anne merged commit 627d912 into pluginsGLPI:develop Sep 7, 2018
@cedric-anne
Copy link
Contributor

Hi,

Thanks for the contribution.

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants