Bug #59992

Persistence session doesn't take overlays into account

Added by Mathias Brodala over 5 years ago. Updated about 1 year ago.

Status:
Accepted
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2014-06-30
Due date:
% Done:

0%

TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

ATM the DataMapper only allows for mapping one record per UID but not additional instances like localized records (e.g. as built by record overlay).

These have the same UID value but their own UID in a separate field (_LOCALIZED_UID). This should be taken into account to allow for mapping localized records in a single session (e.g. for importing data including translations).

datamapper-localizations.patch View - Enable mapping of localized records (1.33 KB) Mathias Brodala, 2014-06-30 11:31


Related issues

Related to TYPO3 Core - Bug #45873: querySettings setRespectSysLanguage or setSysLanguageUid does not work Closed 2013-02-27
Related to TYPO3 Core - Bug #86405: querySetting setRespectSysLanguage (wrong implementation of "strict"-mode) Needs Feedback 2018-09-27
Duplicated by TYPO3 Core - Bug #78026: get translation of extbase object / persistenceSession does not track languages Closed 2016-09-21
Duplicated by TYPO3 Core - Bug #81126: After $querySettings()->setLanguageUid(1); it doesn't change. Closed 2017-05-03

History

#1 Updated by Gerrit Code Review almost 5 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/35163

#2 Updated by Gerrit Code Review almost 5 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/35163

#3 Updated by Mathias Schreiber almost 5 years ago

  • Target version changed from 7.0 to 7.1 (Cleanup)

#4 Updated by Benni Mack over 4 years ago

  • Target version changed from 7.1 (Cleanup) to 7.4 (Backend)

#5 Updated by Mathias Brodala over 4 years ago

This one can be closed as WONTFIX or put on hold, see the linked change.

#6 Updated by Marc Bastian Heinrichs over 4 years ago

  • Tracker changed from Feature to Bug
  • Subject changed from Allow for mapping localized records in a single session to Persistence session doesn't take overlays into account
  • Description updated (diff)
  • Status changed from Under Review to Accepted
  • TYPO3 Version set to 6.2
  • Is Regression set to No

I would say, that is a bug and needs to be tackled. For sure in a different way like in the abandoned patch.

#7 Updated by Daniel Siepmann over 4 years ago

Even using the workaround will still use the same uid for both objects. Saying that, it can create issues while updating the translated record ...
Fixed that for myself by overwriting the getUid() to return _localizedUid if set.:

    public function getUid()
    {
        if($this->_localizedUid > 0) {
            return (int) $this->_localizedUid;
        }
        return parent::getUid();
    }

The workaround is to unregister the entity from the persistence session:
persistenceSession->unregisterObject($entity); where you have to instantiate the persistence Session \TYPO3\CMS\Extbase\Persistence\Generic\Session first via inject or ObjectManager. E.g. inside of your Repository.

#8 Updated by Susanne Moog over 4 years ago

  • Target version changed from 7.4 (Backend) to 7.5

#9 Updated by Benni Mack about 4 years ago

  • Target version deleted (7.5)

#10 Updated by Tymoteusz Motylewski about 1 year ago

  • TYPO3 Version changed from 6.2 to 9
  • PHP Version deleted (5.3)

The issue does still exist in v9.

having query like (where post:2 is in lang 0 and post:11 is translation of post:2)

  $query = $this->postRepository->createQuery();
        $querySettings = $query->getQuerySettings();
        $querySettings->setLanguageUid(0);
        $querySettings->setStoragePageIds([20]);
        $query->matching($query->equals('uid', 2));
        $post2 = $query->execute()->getFirst();

and then query like:

        $query = $this->postRepository->createQuery();
        $querySettings = $query->getQuerySettings();
        $querySettings->setLanguageUid(1);
        $querySettings->setStoragePageIds([20]);
        $query->matching($query->equals('uid', 11));
        $post2 = $query->execute()->getFirst();

You'll get different results depending which query is run first.
or whether you run stuff like

$this->persistenceManager->clearState();

between queries.

In order to get this thing fixed and avoid breaking other things I see following path:
1) extend existing test suite with tests covering translated records and/or rendering of the translated page
- test for building links pointing to an extbase record (when viewing a page with L=1, checking objects with and without translation parent)
- test for form _identity rendering (creating/editing records)
- test for calling findByUid(2) and then findByUid(11) with and without clearing session between calls (while being in the L=1)
2) try to introduce better cache identifier for persistance session

#11 Updated by Tymoteusz Motylewski about 1 year ago

  • Related to Bug #45873: querySettings setRespectSysLanguage or setSysLanguageUid does not work added

#12 Updated by Tymoteusz Motylewski about 1 year ago

  • Duplicated by Bug #81126: After $querySettings()->setLanguageUid(1); it doesn't change. added

#13 Updated by Tymoteusz Motylewski about 1 year ago

  • Related to Bug #86405: querySetting setRespectSysLanguage (wrong implementation of "strict"-mode) added

Also available in: Atom PDF