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

[BUGFIX] Prevent 503 error when field is NULL #478

Closed

Conversation

YKWeyer
Copy link

@YKWeyer YKWeyer commented Feb 5, 2024

Our editors managed to trigger a 503 error (message: trim() expects parameter 1 to be string, null given) in the backend page module by creating menu_categorized_content objects with selected_categories, then turning them into menu_section objects.

Having any value set in DB for selected_categories is apparently enough to enter StandardContentPreviewRenderer::generateListForMenuContentTypes .
https://github.com/TYPO3/typo3/blob/11.5/typo3/sysext/backend/Classes/Preview/StandardContentPreviewRenderer.php#L198 even if the CType doesn't use it.

A possible fix could be to check the right field for the right CType. But a perhaps more robust and flexible solution would be to ensure NULL values would be turned into empty strings.

How to reproduce

Reproduced with TYPO3 version 11.5.34

  1. On a new page, create a menu_categorized_content ContentElement, and select one category in selected_categories
  2. Save
  3. Update the CType to be menu_section
  4. Save and close
  5. Opening the page module for it will result in the following exception:

Whoops, looks like something went wrong.
(1/1) TypeError

trim() expects parameter 1 to be string, null given

@TYPO3IncTeam
Copy link

Thank you for your contribution to TYPO3. We are using Gerrit Code Review for our contributions and took the liberty to convert your pull request to a review in our review system.
You can find your patch at: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82793
For further information on how to contribute have a look at https://docs.typo3.org/typo3cms/ContributionWorkflowGuide/

@TYPO3 TYPO3 locked and limited conversation to collaborators Feb 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants