Bug #89295

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

Added by Frank Berger about 1 year ago. Updated 10 months ago.

Needs Feedback
Should have
Target version:
Start date:
Due date:
% Done:


TYPO3 Version:
PHP Version:
extbase repository
Is Regression:
Sprint Focus:


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);

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

extbase-querysettings.diff View - Patchfile for this issue (4.44 KB) Frank Berger, 2019-09-27 16:20

Related issues

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


#1 Updated by Frank Berger about 1 year ago

  • Tags set to extbase repository
  • Complexity set to medium

#2 Updated by Alexander Schnitzler 10 months ago

  • Status changed from New to Needs Feedback

I cannot reproduce this issue.
It's true that the query factory does not respect query settings, but in \TYPO3\CMS\Extbase\Persistence\Repository::createQuery, which is called by the findAll (and magic) method(s), the defaultQuerySettings (if present) are copied over to the query object.

Please see https://github.com/TYPO3/TYPO3.CMS/blob/v9.5.13/typo3/sysext/extbase/Classes/Persistence/Repository.php#L201 for more information.

If I misunderstood the problem, please provide further feedback.

#3 Updated by Frank Berger 10 months ago

  • Assignee set to Alexander Schnitzler

The Problem is here:


This is called before the defaultQuerySettings are applied in


Which means if you just use defaultQuerySettings you will override any preconfigured or contextrelated storagePageIds

therefore either the setting of the storagePageIds need to be done later - i.e. in Repository->createQuery after the clone OR the defaultQuerySettings need to be applied before, like in the patch I suggested..

sorry if that was not clear in my initial report

#4 Updated by Frank Berger 10 months ago

sorry, in hindsight - which is 20-20 - I should have lead with that..

#5 Updated by Georg Ringer 7 months ago

  • Related to Bug #88372: Extbase QuerySettings ignores SiteConfiguration language settings added

Also available in: Atom PDF