Issue Bug New

#105843Language fallback broken for objectstorages

Jan Kornblum 12/18/24, 10:22 updated 11/11/26, 22:00

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

History 12

  1. Garvin Hicking commented <span data-processor="relativetime" data-value="2024-12-18T15:17:52+00:00" > 12/18/24, 15:17 </span>

    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)

  2. 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).

  3. 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 do findByUid(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.

  4. 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.

  5. 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 main branch (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.post holds 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 (RecordFactory with getLanguageOverlay() 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 RelationsOfTranslationsReadTest are 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.