Project

General

Profile

Actions

Bug #102635

closed

\TYPO3\CMS\Extbase\Persistence\Repository->findByUid does not respect defaultQuerySettings

Added by This Mächler 12 months ago. Updated 2 days ago.

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

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
8.1
Tags:
Repository, Extbase, findByUid, querySettings, defaultQuerySettings
Complexity:
Is Regression:
Sprint Focus:

Description

Settings by

$this->setDefaultQuerySettings( )

in
\TYPO3\CMS\Extbase\Persistence\Repository

will not be respected when calling

\TYPO3\CMS\Extbase\Persistence\Repository->findByUid()

For example with these settings

$this->defaultQuerySettings = $this->createQuery()->getQuerySettings()
    ->setEnableFieldsToBeIgnored(['disabled'])
    ->setIgnoreEnableFields( true );
$this->setDefaultQuerySettings( $this->defaultQuerySettings );

native findByUid will will hidden / disabled records. A custom findByUid fixes this:

public function findByUid($uid)
{
    $query = $this->createQuery();
    $query->matching( $query->equals('uid', $uid) );
    $result = $query->execute();
    return $result->getFirst();
}

Actions

Also available in: Atom PDF