[BUGFIX] Only include records with the correct language in backend preview #55
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.
Typo3-Version: 11.5.30
Gridelements-Version: 11.1.0
I have encountered an interesting problem when copying records between grid-elements on different sites.
In this case there is a site that supports German and French (language_ids 0 and 2 respectively) and another site that supports German and English (language_ids 0 and 1 respectively). A translated record was copied from the German-French site to the German-English site which results in the "web"-Module crashing in the backend.
The reason for the crash is that the
GridelementsPreviewRenderer.php::renderGridContainer()function usesHelper::getChildren()to fetch all children of a Gridelement regardless of their language. Because the French version was copied as well there is now a Record in this children array that has a sys_language_uid field that should not exist on this page. When not in a Gridelement Context typo3 just ignores these records.The partial
Resources/Private/Backend/Gridelements/Partials/PageLayout/Record/Header.htmllater tries to resolve{item.siteLanguage.flagIdentifier}which results in a LogicException being thrown because the current page does not support the language with, in this case, 2.I don't know if the Helper Class should just respect the current language. This fix instead just filters any record that does not match the currently selected language from the childRecord array, so it is ignored in the preview.