fix(search): order default lists by first visible column again - #25221
Open
iPaulis wants to merge 1 commit into
Open
fix(search): order default lists by first visible column again#25221iPaulis wants to merge 1 commit into
iPaulis wants to merge 1 commit into
Conversation
In SearchEngine::prepareDataForSearch(), when the user has not set an explicit sort, the default sort is set to the first visible column on $p['sort'] — but $data['search'] was snapshotted earlier, so the changed sort was never propagated back to it. SQLProvider::constructSQL() then read $data['search']['sort'] (still [0]), which never matched any visible column, so the generated ORDER BY fell back to the hidden id column. Synchronize $data['search']['sort'] with the corrected default so the provider orders by the first visible column, restoring the GLPI 10 behavior. Fixes glpi-project#25208.
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.
Fix default sorting: order lists by first visible column again
Fixes #25208
Problem
Since GLPI 11, default list views (Users, Computers, Groups, Entities, Locations, Change, Problem, …) are silently sorted by the
idcolumn instead of the first visible column when the user has not explicitly chosen a sort. The list looks "unsorted" / ordered by an invisible column.In GLPI 10 the same lists were sorted by the first visible column by default. Clicking a column header still sorts correctly — the bug only affects the default case (fresh session / no stored sort).
Root cause
In
SearchEngine::prepareDataForSearch():$data['search']is copied before the default sort substitution, so the later$p['sort']assignment is never propagated back.SQLProvider::constructSQL()then reads$data['search']['sort'](still[0]), which never matches any element oftocomputein the ORDER BY loop, so the fallbackORDER BY idis used.Change
One-line synchronization of the corrected default sort back into
$data['search']:Verification
11.0/bugfixes.ORDER BY ITEM_<ItemType>_<first visible searchopt> ASC(e.g.ORDER BY name ASCfor Users,ITEM_Computer_1,ITEM_Group_1,ITEM_Entity_1,ITEM_Location_1,ITEM_Change_2, …) instead ofORDER BY id.php -lclean.