fix: avoid null array offset in rex_list::getSortColumn() under PHP 8.5#6586
Merged
gharlan merged 3 commits intoJul 10, 2026
Merged
Conversation
When the `list` request parameter matches the list name but no `sort` parameter is present, `$sortColumn` is null. Passing it to hasColumnOption() results in isset($this->columnOptions[null][...]). Since PHP 8.5, using null as an array offset raises a deprecation even inside isset()/empty()/?? (it was silently tolerated up to 8.4), so this emits "Using null as an array offset is deprecated" on every affected list render (e.g. the metainfo field list after saving a field, where the return URL carries `list=` but not `sort`). The null check short-circuits before hasColumnOption() and keeps the existing behaviour: getSortColumn() still returns $default when the requested sort column is missing or not whitelisted. The affected code path was introduced with the sort-column whitelist validation in redaxo#6580.
Member
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.
Problem
Auf PHP 8.5 erscheint beim Rendern einer
rex_listdie Deprecation:Ablauf:
getSortColumn()prüftif (rex_request('list', 'string') == $this->getName()).list-Parameter gesetzt, aber keinsort-Parameter, liefertrex_request('sort', 'string', $default)mit$default === null→$sortColumn = null.hasColumnOption($sortColumn, …)führt dannisset($this->columnOptions[null][…])aus.null-Array-Offset die Deprecation auch innerhalb vonisset()/empty()/??— bis 8.4 wurde das stillschweigend als''toleriert.Gut reproduzierbar in der Metainfo-Feldverwaltung: Nach dem Speichern eines Feldes trägt die Rücksprung-URL
list=…, aber keinsort=…→ die Meldung erscheint. Beim direkten Aufruf der Übersicht (ohnelist-Parameter) wird der Zweig übersprungen, daher tritt sie dort nicht auf.Der betroffene Code-Pfad wurde mit der Sortier-Spalten-Whitelist-Validierung aus #6580 eingeführt.
Fix
Null-Guard vor dem
hasColumnOption()-Aufruf:Verhaltensneutral: Ist die angeforderte Sortier-Spalte nicht gesetzt oder nicht in der Whitelist, gibt
getSortColumn()weiterhin$defaultzurück.Test
php -lfehlerfrei.isset($arr[null][null])löst die Deprecation aus, mit Guard nicht mehr.🤖 Generated with Claude Code