Issue Bug Closed

#92520DBAL-DriverException in BE module SYSTEM->"Backend users" when searching by username on PostgreSQL

Stephan Großberndt 10/08/20, 17:33 updated 12/22/20, 11:04

Description

Just found a bug in TYPO3 backend module SYSTEM->Backend users when using PostgreSQL. If you enter any text in the filter text field “Username” and send the search you get a Doctrine\DBAL\Exception\DriverException.

This happens because of
@typo3/sysext/beuser/Classes/Domain/Repository/BackendUserRepository.php@:

            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_users');
            foreach (['userName', 'uid', 'realName'] as $field) {
                $searchConstraints[] = $query->like(
                    $field,
                    '%' . $queryBuilder->escapeLikeWildcards($demand->getUserName()) . '%'
                );
            }
            $constraints[] = $query->logicalOr($searchConstraints);

which searches for uid (an int column) using LIKE which probably will fail on MSSQL and SQLite too. There is no direct replacement which is database platform agnostic to my knowledge.

As discussed on Slack we simply go for $constraints[] = $query->equals('uid', (int)$demand->getUserName()); instead to only directly show backend user 4 when searching for 4 instead of showing 4 and 14.

Reviews 3