#105843Language fallback broken for objectstorages
Description
Language fallbacks currently don’t work for objectstorages (and possibly other relation types too). Example use case:
- Post 1:n> Comment (“inline” relation in TCA, objectstorage in Extbase)
- Post records are localized (L=0 + L=1)
- Comment records are NOT localized (only exist in L=0)
- Site configuration “fallbackType” is “fallback” (with L=1 fallback to L=0)
Now showing a “Post” record in frontend in L=1, it doesn’t show any related “Comment” records at all (when using $post->getComments()). Even when the “Comment” records are set to sys_language_uid = -1 they won’t show up. As a workaround, instead of using $post->getComments() , i’ve added an own repository method $commentRepository->findByPost() like following:
class CommentRepository extends Repository
{
public function findByPost(Post $post): QueryResultInterface|array
{
$query = $this->createQuery();
$query->matching(
$query->equals('post', $post->getUid()) // This uid comparision is the important part!
//$query->equals('post', $post) // This fails
);
return $query->execute();
}
}
This way the fallback behaviour works fine! The important part here is, that the constraint must explicitly compare against the “uid” (using $post->getUid() ). The “magic” repository method findBy***() fails here, too, because it down’t seem to compare against the “uid” internally.
So i guess, there are some parts in core where this kind of uid comparison is still missing.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Fix this issue
Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch
- Commit message
-
[BUGFIX] Language fallback broken for objectstorages Resolves: #105843 Releases: main
Related issues 6
- Bug #89768l10n_mode "exclude" does not work with inline type
- Bug #90430Language handling of bidirectional mm selects is not consitent.
- Feature #94539Documentation on how to work with 1:n and n:1 relations and translations
- Bug #102336Add support for localizing n:1 relations
- Bug #106483Exception 1546632293 Could not get value of property [model] make sure the property is either public or has a getter
- Epic #108986Improve MM handling in TYPO3 Core related to language + workspace concepts
History 12
-
Garvin Hicking commented <span data-processor="relativetime" data-value="2024-12-18T15:17:52+00:00" > 12/18/24, 15:17 </span>
-
Jan Kornblum commented <span data-processor="relativetime" data-value="2024-12-18T15:24:09+00:00" > 12/18/24, 15:24 </span>
Garvin Hicking wrote in #note-1:
> I’ve worked around this occassionally by using sys_language_uid=-1 here; then “all languages” is triggered more specifically.Thats what i’ve already tried yesterday in v12. But even with “sys_language_uid=-1” that didn’t work (see above).
-
Tymoteusz Motylewski changed removed the assignee <span data-processor="relativetime" data-value="2024-12-23T18:36:43+00:00" > 12/23/24, 18:36 </span>
-
Jan Kornblum changed Related to #94539 <span data-processor="relativetime" data-value="2025-01-07T11:12:27+00:00" > 01/07/25, 11:12 </span>
-
Jan Kornblum changed Related to #102336 <span data-processor="relativetime" data-value="2025-01-07T11:14:20+00:00" > 01/07/25, 11:14 </span>
-
Jan Kornblum changed Related to #89768 <span data-processor="relativetime" data-value="2025-01-07T11:14:34+00:00" > 01/07/25, 11:14 </span>
-
Jan Kornblum changed Related to #90430 <span data-processor="relativetime" data-value="2025-01-07T18:37:43+00:00" > 01/07/25, 18:37 </span>
-
S P commented <span data-processor="relativetime" data-value="2025-06-10T10:27:36+00:00" > 06/10/25, 10:27 </span>
Can confirm, sort of. I am on v13, my use-case:
Domain model with ObjectStorage relation to other entities of the same table.
When I am in FE L>0 context and do a
findByUid()call, then Extbase overlays this exact object correctly, but the objects inside the ObjectStorage are all in L=0.This also has the super-unintuitive side-effect that when doing two consecutive
findByUid()calls (on different UIDs), that the second one can end up in L=0, because it already implicitly is in the persistence session when being fetched for the ObjectStorage of the first object!Example: doing
findByUid(1); findbyUid(2);gets object 1 in L>1 and object 2 in L=0, but if you dofindByUid(2); findbyUid(1)it results exactly in the other way round – just because they are related by an ObjectStorage and whichever is called explicitly first gets correctly overlayed and the other one (being fetched implicitly by an ObjectStorage relation) is not overlayed. -
S P commented <span data-processor="relativetime" data-value="2025-06-11T05:21:27+00:00" > 06/11/25, 05:21 </span>
For anyone stumbling in here: In my case using
#[Lazy]on the ObjectStorage did the trick.Also, as a side-observation in #106483 another curious limitation of ObjectStorages came up (a model can not have a non-TCA ObjectStorage). It seems since v12 that ObjectSrorages in general are kind of broken.
-
Benni Mack changed Related to #108986 <span data-processor="relativetime" data-value="2026-02-15T17:19:28+00:00" > 02/15/26, 17:19 </span>
-
Georg Ringer commented <span data-processor="relativetime" data-value="2026-11-11T22:00:39+00:00" > 11/11/26, 22:00 </span>
I checked this against the current
mainbranch (15.0.0-dev) with the blog example fixture of the Extbase functional tests.Setup: a post in the default language and a German translation of it, two comments that exist only for the default post (
comments.postholds the uid of the default post), and a request in German with overlays mixed and English as fallback (fallbackType: fallback).Result:
$post->getComments()is empty. The record API of the core (RecordFactorywithgetLanguageOverlay()and$record->get('comments')) returns the same empty result, so this is not a difference between Extbase and the core. In both cases the relation of a translated parent is resolved with the uid of the translation, so child records that only point to the default record are not found.This matches the workaround from the description: comparing against the uid of the default post finds the comments, because they point to that record. It is the same cause as in #91487, where Extbase binds the uid of the translation while the relation holds the uid of the default record (the corresponding tests in
RelationsOfTranslationsReadTestare skipped with a reference to that issue). #102336 and the epic #108986 deal with the language and workspace handling of these relations.So I think this should not be handled separately but together with #91487 / #108986. I did not check how it behaves in v12 / v13, and I did not look at other relation types than inline (
ObjectStorage) for this.
I’ve worked around this occassionally by using sys_language_uid=-1 here; then “all languages” is triggered more specifically.
(Not saying this issue here is [not] a bug, just stating another possible setuo)