Project

General

Profile

Actions

Bug #89295

closed

Typo3QuerySettings set as DefaultQuerySettings in a Repositories initializeObject Method are not honored

Added by Frank Berger over 4 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2019-09-27
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
extbase repository
Complexity:
medium
Is Regression:
Sprint Focus:

Description

The premise is that an Extbase Repository has been extended from Repository, and the initializeObject Method is used to set Typo3QuerySettings and stored in $this->setDefaultQuerySettings, for example like this:

class EventRepository extends Repository
{
    public function initializeObject()
    {
        $querySettings = $this->objectManager->get(Typo3QuerySettings::class);
        $context = GeneralUtility::makeInstance(Context::class);
        $querySettings->setLanguageUid($context->getPropertyFromAspect('language','id'));
        $querySettings->setLanguageOverlayMode(1);
        $this->setDefaultQuerySettings($querySettings);
    }
}

The reason why we set for example the language like this has a different issue, which will be a different bug report. This is just an example.

The expected behaviour now is that any method using $this->createQuery(), including the magic findX methods and findAll will now use these settings.

This does not happen as in Generic\QueryFactory->create a new DefaultQuery is generated.

public function create($className)
{
         $query = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\QueryInterface::class, $className);
         $querySettings = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface::class);

This has several side effects. Parts of 'our' defaultQuerySettings are used, parts of the new one are used. And anything related to the storagePageIds will fail (no storagePageId will be set in the querySettings, not from typoscript or the the pages field or flexform)

We patched in our project the call-chain down to Generic\QueryFactory->create so the repositories defaultQuerySettings will be passed through the instances and if not null will be used instead if a new instance.

The patch is attached.

The System behaves as expected after that, honoring the settings set in a initializeObject method, even for the magic Methods


Files

extbase-querysettings.diff (4.44 KB) extbase-querysettings.diff Patchfile for this issue Frank Berger, 2019-09-27 16:20
extbase-querysettings-10.diff (4.54 KB) extbase-querysettings-10.diff Markus Hofmann, 2020-11-09 18:46

Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #88372: Extbase QuerySettings ignores SiteConfiguration language settingsClosed2019-05-16

Actions
Related to TYPO3 Core - Bug #83296: Doctrine respects wrong storage PIDs for sys_categoryClosed2017-12-12

Actions
Actions

Also available in: Atom PDF