Project

General

Profile

Actions

Bug #91661

open

Wrong recordType constraint in default FrontendUserRepository if subclass of FrontendUser exists

Added by Tobias Schmidt over 4 years ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2020-06-16
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.4
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

In versions prior to TYPO3 10 in Extbase's TypoScript configuration the persistence subkey could be used in different scopes: config.tx_extbase, plugin.tx_extensionname and plugin.tx_extensionname_pluginname. In TYPO3 10 this configuration is done in PHP in Configuration/Extbase/Persistence/Classes.php with a global scope like config.tx_extbase. There is no possibility to set a non-global scope.

Until TYPO3 10 the persistence configuration of a subclass of FrontendUser could be set to a non-global scope in TypoScript like this:

plugin.tx_extensionname {
  persistence{
    classes{
      TYPO3\CMS\Extbase\Domain\Model\FrontendUser {
        subclasses {
          Tx_Extensionname_Modelname = Vendor\Extensionname\Domain\Model\Modelname
        }
      }
      Vendor\Extensionname\Domain\Model\Modelname {
        mapping {
          tableName = fe_users
          recordType = Tx_Extensionname_Modelname
        }
      }
    }
  }
}

In TYPO3 10 the persistence configuration can only be set to a gobal scope in PHP like this:

return [
    \Vendor\Extensionname\Domain\Model\Modelname::class => [
        'tableName' => 'fe_users',
        'recordType' => 'Tx_Extensionname_Modelname',
    ],
    \TYPO3\CMS\Extbase\Domain\Model\FrontendUser::class => [
        'subclasses' => [
            \Vendor\Extensionname\Domain\Model\Modelname::class,
        ]
    ]
];

The change from non-global to global scope breaks method addRecordTypeConstraint in TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser if at least one subclass exists. With a non-global scope no constraint was added from a query out of this scope. Now in TYPO3 10 a constraint for the subclass is always added because the persistence configuration is in global scope. It is impossible to query a default FrontendUser without a recordType set. $this->frontendUserRepository->findByUsergroup($usergroup) for example returns no records without a recordType set because a constraint for the recordType of the subclass is added.

As a workaround I added a recordType for the default FrontendUser class and additionally set the recordType of existing FrontendUser records to this value:

\TYPO3\CMS\Extbase\Domain\Model\FrontendUser::class => [
    'recordType' => 'Tx_Extbase_Domain_Model_FrontendUser',
]

No data to display

Actions

Also available in: Atom PDF