[BUGFIX] Fix for colPos handling in ColumnPositionItems.php #2236
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.
Description
This pull request fixes a bug in the colPosListItemProcFunc method of the ColumnPositionItems class. The issue occurred when the $parameters['row']['colPos'] value was not set, which led to incorrect or unexpected behavior when calculating the parent record UID. By ensuring that the colPos value is checked and cast to an integer (defaulting to 0 when not set), we prevent potential runtime errors and ensure consistent behavior.
Motivation
The bug was reported in scenarios where the colPos parameter was missing from the $parameters array. Since this value is critical for determining the parent record UID via the ColumnNumberUtility::calculateParentUid() method, missing or invalid data could lead to issues in rendering the backend layout columns. This fix enhances the robustness of the code by providing a reliable fallback and avoiding errors.
Changes Made
Added a check for the existence of $parameters['row']['colPos'].
Cast the value to an integer, defaulting to 0 if not set.
Updated the calculation of parentRecordUid to use the safe, validated colPos value.
Testing
Manually verified that the patch applies correctly.
Confirmed that the fix resolves the issue when the colPos parameter is missing.
All existing tests pass without modification.
Backwards Compatibility
This is a non-breaking bugfix. The change introduces a safe fallback for missing data without altering the intended behavior when the colPos is provided.
Related Issues
No related issue has been linked to this PR yet.