Bug #88951
closedExtbase does not handle page translations correctly when using consistentTranslationOverlayHandling
100%
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
Updated by Lars Peter Søndergaard over 4 years ago
- File typo3dbbackend.patch typo3dbbackend.patch added
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.
Updated by Benni Mack 4 months ago
- Related to Bug #102627: Streamline _PAGES_OVERLAY_UID and _LOCALIZED_UID magic getters added
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
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
Updated by Benni Mack 4 months ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 9fb117d594a79e114e13a84123a6c924f7f87503.