Project

General

Profile

Actions

Bug #88951

closed

Extbase does not handle page translations correctly when using consistentTranslationOverlayHandling

Added by Lars Peter Søndergaard over 4 years ago. Updated 4 months ago.

Status:
Resolved
Priority:
Should have
Category:
Extbase + l10n
Target version:
-
Start date:
2019-08-12
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

My scenario:

I mapped the "pages" table to an extbase model named "Product", using a custom doktype. So in ext_typoscript_setup.typoscript I have something like this:

config.tx_extbase {
    persistence {
        classes {
            LFM\MyProducts\Domain\Model\Product {
                mapping {
                    tableName = pages
                    recordType = 133
                    columns {
                        doktype.mapOnProperty = doktype
                        l10n_parent.mapOnProperty = parentRecord
                    }
                }
            }
        }
    }
}

This works fine, until I try to read records using a "ProductRepository".

Let's say, we got a "product" page with uid=5, and a translation of that page, with uid=6 and l10n_parent=5.

Using productRepository->findAll() in context of default language, everything works as expected. Product object with uid=5 is returned. In context of the translated language, the findAll method however returns an object that has uid set to 6 instead of 5, and _localizedUid is set to 6 as well.

I tried to test the same with a "normal" Dummy model that is mapped to a regular "tx_myproducts_domain_model_dummy" table. Using that, everything works exactly as expected. (having default language uid=1 and translation uid=2, findAll() returns uid=1 in both default language context as well as translated context, with only _localizedUid having value 2 in translated context).

The primary suspect seems to be the method \TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend::overlayLanguageAndWorkspace.


Some tests have shown that extbase always fetches the translated records in translated context. So the passed $rows array in that overlayLanguageAndWorkspace method contains a list of translated page records. For non-pages records it seems there is a "fix" to pretend to be a default language record, before calling getRecordOverlay, but the same thing is not done for pages record. Instead getPageOverlay is called directly with the (presumably incorrect) translated records.


Files

typo3dbbackend.patch (4.16 KB) typo3dbbackend.patch Lars Peter Søndergaard, 2019-09-27 09:03

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #102627: Streamline _PAGES_OVERLAY_UID and _LOCALIZED_UID magic gettersClosedBenni Mack2023-12-07

Actions
Actions #1

Updated by Lars Peter Søndergaard over 4 years ago

The primary issue seems to be, that $pageRepository->getPageOverlay returns an array with a _PAGES_OVERLAY_UID key and $pageRepository->getRecordOverlay returns an array with a _LOCALIZED_UID, and only the latter is used by extbase later on to properly handle translations.

I attached a patch with a fix that seems to work so far.
It reorders a section of the code (concerning cases where respect language is false), though I'm not sure that part is correct.

The primary fix was remapping the _PAGES_OVERLAY_UID to _LOCALIZED_UID.

The same issue might also exist for the other (old) doLanguageAndWorkspaceOverlay, but I ignored that one, since it's removed on master.

Actions #2

Updated by Benni Mack 4 months ago

  • Related to Bug #102627: Streamline _PAGES_OVERLAY_UID and _LOCALIZED_UID magic getters added
Actions #3

Updated by Gerrit Code Review 4 months ago

  • Status changed from New to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82147

Actions #4

Updated by Gerrit Code Review 4 months ago

Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82117

Actions #5

Updated by Benni Mack 4 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF