Skip to content

fix: apply sort request for columns marked sortable after list construction - #6589

Merged
gharlan merged 1 commit into
5.xfrom
fix-list-sort
Jul 16, 2026
Merged

fix: apply sort request for columns marked sortable after list construction#6589
gharlan merged 1 commit into
5.xfrom
fix-list-sort

Conversation

@gharlan

@gharlan gharlan commented Jul 15, 2026

Copy link
Copy Markdown
Member

Fixes #6585

Problem

Since the sort column is validated against the sortable columns (GHSA-4f5f-j737-pm58, #6580), sorting via column headers stopped working: the query runs in the rex_list constructor, but setColumnSortable() is called afterwards, so the whitelist was always empty at the time prepareQuery() built the ORDER BY.

Solution

When a sort request is pending (list param matches and sort param present), the constructor no longer loads the data. It fetches only the field names via a LIMIT 0 metadata query (optimized away by MySQL, needed for getColumnNames()/addColumn() etc.) and defers the data query to get() — at that point all sortable columns are registered, including those added via the REX_LIST_GET extension point.

  • Requests without a sort param behave exactly as before (no additional query).
  • Sorted views: count + LIMIT 0 metadata + one data query with the validated ORDER BY.
  • Non-whitelisted sort params still fall back to the default order (security fix stays intact, covered by a new test).
  • getRows()/getValue() lazily trigger the initial data load in case they are used before get(); get() re-executes only if the effective query changed in the meantime.

Note: existing rex_list behavior is unchanged in that a query with a hardcoded ORDER BY (and no $defaultSort) still ignores sort requests — use the $defaultSort factory parameter instead.

Verified end-to-end in the backend (users list, cronjobs list with temporarily enabled sortable columns): default sort, asc/desc via column headers, and rejected non-sortable columns.

…uction

Since the sort column is validated against the sortable columns
(GHSA-4f5f-j737-pm58), sorting via column headers stopped working:
the query runs in the rex_list constructor, but setColumnSortable()
is called afterwards, so the whitelist was always empty at that point.

When a sort request is pending, the constructor now fetches only the
field names (via a free LIMIT 0 metadata query) and defers the data
query to get(), where all sortable columns are registered (including
those added via the REX_LIST_GET extension point).
@rex-bot rex-bot added the bug label Jul 15, 2026
@gharlan gharlan added this to the REDAXO 5.21.3 milestone Jul 15, 2026
@gharlan
gharlan merged commit eca40e9 into 5.x Jul 16, 2026
18 checks passed
@gharlan
gharlan deleted the fix-list-sort branch July 16, 2026 10:18
@bitshiftersgmbh

Copy link
Copy Markdown
Contributor

Danke @gharlan <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

Nach dem Security-Fix an rex_list funktioniert Sortierung nicht mehr

3 participants