#102635\TYPO3\CMS\Extbase\Persistence\Repository->findByUid does not respect defaultQuerySettings
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();
}Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
History 2
-
Torben Hansen commented and changed status
NewNeeds Feedback <span data-processor="relativetime" data-value="2024-06-02T05:41:10+00:00" > 06/02/24, 05:41 </span> -
Benni Mack commented and changed status
Needs FeedbackClosed <span data-processor="relativetime" data-value="2024-11-22T15:45:14+00:00" > 11/22/24, 15:45 </span>Agreeing with Torben, I will close this issue. It’s exactly as expected in Core.
I would say, this is expected behavior for the
findByUidmethod and should not be changed in extbase, because the method is also used to retrieve objects for mapped action arguments. So if you for example would define default query settings for a repository, which allows to show hidden record, it would now by default be possible to show hidden records in actions, which might result in possible sensitive information disclosure.So basically, your approach to create a custom function is right to retrieve objects with e.g hidden state, but I would recommend to use a differnt name in order to prevent unwanted side effects.