getArrayBindingType method from the BasicEntityPersister is missing binary #7374

Open
opened 2026-01-22 15:50:52 +01:00 by admin · 4 comments
Owner

Originally created by @delolmo on GitHub (May 28, 2024).

Bug Report

Q A
BC Break yes
Version 3.2.0

Summary

The getArrayBindingType method from the BasicEntityPersister is missing the binary type.

My guess is this:

        return match ($type) {
            ParameterType::STRING => ArrayParameterType::STRING,
            ParameterType::INTEGER => ArrayParameterType::INTEGER,
            ParameterType::ASCII => ArrayParameterType::ASCII,
        };

should be changed to this:

        return match ($type) {
            ParameterType::STRING => ArrayParameterType::STRING,
            ParameterType::INTEGER => ArrayParameterType::INTEGER,
            ParameterType::ASCII => ArrayParameterType::ASCII,
            ParameterType::BINARY => ArrayParameterType::BINARY,
        };

Need expert hands though to evaluate the problem.

Current behavior

Right now, when using binary fields, the following exception can be thrown under certain circumstances (I suspect it happens when retrieving entities with associations):

PHP Fatal error:  Uncaught UnhandledMatchError: Unhandled match case of type Doctrine\DBAL\ParameterType in (...)/vendor/doctrine/orm/src/Persisters/Entity/BasicEntityPersister.php:1911

How to reproduce

Not sure how to tbh.

Expected behavior

Should not throw an error.

Originally created by @delolmo on GitHub (May 28, 2024). ### Bug Report | Q | A |------------ | ------ | BC Break | yes | Version | 3.2.0 #### Summary The `getArrayBindingType` method from the `BasicEntityPersister` is missing the binary type. My guess is [this](https://github.com/doctrine/orm/blob/9d4f54b9a476f13479c3845350b12c466873fc42/src/Persisters/Entity/BasicEntityPersister.php#L1908): ```php return match ($type) { ParameterType::STRING => ArrayParameterType::STRING, ParameterType::INTEGER => ArrayParameterType::INTEGER, ParameterType::ASCII => ArrayParameterType::ASCII, }; ``` should be changed to this: ```php return match ($type) { ParameterType::STRING => ArrayParameterType::STRING, ParameterType::INTEGER => ArrayParameterType::INTEGER, ParameterType::ASCII => ArrayParameterType::ASCII, ParameterType::BINARY => ArrayParameterType::BINARY, }; ``` Need expert hands though to evaluate the problem. #### Current behavior Right now, when using binary fields, the following exception can be thrown under certain circumstances (I suspect it happens when retrieving entities with associations): ```text PHP Fatal error: Uncaught UnhandledMatchError: Unhandled match case of type Doctrine\DBAL\ParameterType in (...)/vendor/doctrine/orm/src/Persisters/Entity/BasicEntityPersister.php:1911 ``` #### How to reproduce Not sure how to tbh. #### Expected behavior Should not throw an error.
Author
Owner

@greg0ire commented on GitHub (May 28, 2024):

When opening the file with my IDE, I get this warning: Match expression does not handle remaining values: Doctrine\DBAL\ParameterType::BINARY|Doctrine\DBAL\ParameterType::BOOLEAN|Doctrine\DBAL\ParameterType::LARGE_OBJECT|Doctrine\DBAL\ParameterType::NULL. You might be on to something. Would be great to have a reproducer though. A stack trace might help as well.

@greg0ire commented on GitHub (May 28, 2024): When opening the file with my IDE, I get this warning: `Match expression does not handle remaining values: Doctrine\DBAL\ParameterType::BINARY|Doctrine\DBAL\ParameterType::BOOLEAN|Doctrine\DBAL\ParameterType::LARGE_OBJECT|Doctrine\DBAL\ParameterType::NULL`. You might be on to something. Would be great to have a reproducer though. A [stack trace](https://symfony.com/doc/current/contributing/code/stack_trace.html#getting-stack-traces-with-symfony) might help as well.
Author
Owner

@sips-dan-s commented on GitHub (Jan 15, 2025):

This affects us as well. We are using Ramsey/Uuid-Doctrine's UuidBinaryType type for primary (and foreign) keys in some tables, and when there's a Doctrine 'eager fetch' in place, the auto-generated internal query to fetch the 'child' records (along the lines of SELECT child_record FROM child_table WHERE id IN (...)) is hitting this issue.

It's not even something we can really work around without completely re-writing the query, as it is internal to Doctrine.

Stack trace (slightly trimmed but leaving all the Doctrine internal calls intact):

UnhandledMatchError: Unhandled match case of type Doctrine\DBAL\ParameterType in
/var/www/vendor/doctrine/orm/src/Persisters/Entity/BasicEntityPersister.php:1942
Stack trace:
#0 [internal function]: Doctrine\ORM\Persisters\Entity\BasicEntityPersister->getArrayBindingType()
#1 /var/www/vendor/doctrine/orm/src/Persisters/Entity/BasicEntityPersister.php(1926): array_map()
#2 /var/www/vendor/doctrine/orm/src/Persisters/Entity/BasicEntityPersister.php(1850):
Doctrine\ORM\Persisters\Entity\BasicEntityPersister->getTypes()
#3 /var/www/vendor/doctrine/orm/src/Persisters/Entity/BasicEntityPersister.php(937):
Doctrine\ORM\Persisters\Entity\BasicEntityPersister->expandParameters()
#4 /var/www/vendor/doctrine/orm/src/UnitOfWork.php(2620): Doctrine\ORM\Persisters\Entity\BasicEntityPersister->loadAll()
#5 /var/www/vendor/doctrine/orm/src/Internal/Hydration/ObjectHydrator.php(120):
Doctrine\ORM\UnitOfWork->triggerEagerLoads()
#6 /var/www/vendor/doctrine/orm/src/Internal/Hydration/AbstractHydrator.php(170):
Doctrine\ORM\Internal\Hydration\ObjectHydrator->cleanup()
#7 /var/www/vendor/doctrine/orm/src/AbstractQuery.php(948):
Doctrine\ORM\Internal\Hydration\AbstractHydrator->hydrateAll()
#8 /var/www/vendor/doctrine/orm/src/AbstractQuery.php(891): Doctrine\ORM\AbstractQuery->executeIgnoreQueryCache()
#9 /var/www/vendor/doctrine/orm/src/AbstractQuery.php(738): Doctrine\ORM\AbstractQuery->execute()
#10 /var/www/src/App/src/Doctrine/Repository/MyRepository.php(182):
Doctrine\ORM\AbstractQuery->getOneOrNullResult()
@sips-dan-s commented on GitHub (Jan 15, 2025): This affects us as well. We are using [Ramsey/Uuid-Doctrine](https://github.com/ramsey/uuid-doctrine/blob/main/src/UuidBinaryType.php)'s `UuidBinaryType` type for primary (and foreign) keys in some tables, and when there's a Doctrine 'eager fetch' in place, the auto-generated internal query to fetch the 'child' records (along the lines of `SELECT child_record FROM child_table WHERE id IN (...)`) is hitting this issue. It's not even something we can really work around without completely re-writing the query, as it is internal to Doctrine. Stack trace (slightly trimmed but leaving all the Doctrine internal calls intact): ``` UnhandledMatchError: Unhandled match case of type Doctrine\DBAL\ParameterType in /var/www/vendor/doctrine/orm/src/Persisters/Entity/BasicEntityPersister.php:1942 Stack trace: #0 [internal function]: Doctrine\ORM\Persisters\Entity\BasicEntityPersister->getArrayBindingType() #1 /var/www/vendor/doctrine/orm/src/Persisters/Entity/BasicEntityPersister.php(1926): array_map() #2 /var/www/vendor/doctrine/orm/src/Persisters/Entity/BasicEntityPersister.php(1850): Doctrine\ORM\Persisters\Entity\BasicEntityPersister->getTypes() #3 /var/www/vendor/doctrine/orm/src/Persisters/Entity/BasicEntityPersister.php(937): Doctrine\ORM\Persisters\Entity\BasicEntityPersister->expandParameters() #4 /var/www/vendor/doctrine/orm/src/UnitOfWork.php(2620): Doctrine\ORM\Persisters\Entity\BasicEntityPersister->loadAll() #5 /var/www/vendor/doctrine/orm/src/Internal/Hydration/ObjectHydrator.php(120): Doctrine\ORM\UnitOfWork->triggerEagerLoads() #6 /var/www/vendor/doctrine/orm/src/Internal/Hydration/AbstractHydrator.php(170): Doctrine\ORM\Internal\Hydration\ObjectHydrator->cleanup() #7 /var/www/vendor/doctrine/orm/src/AbstractQuery.php(948): Doctrine\ORM\Internal\Hydration\AbstractHydrator->hydrateAll() #8 /var/www/vendor/doctrine/orm/src/AbstractQuery.php(891): Doctrine\ORM\AbstractQuery->executeIgnoreQueryCache() #9 /var/www/vendor/doctrine/orm/src/AbstractQuery.php(738): Doctrine\ORM\AbstractQuery->execute() #10 /var/www/src/App/src/Doctrine/Repository/MyRepository.php(182): Doctrine\ORM\AbstractQuery->getOneOrNullResult() ```
Author
Owner

@sips-dan-s commented on GitHub (May 7, 2025):

Hi, any update on this at all?

@sips-dan-s commented on GitHub (May 7, 2025): Hi, any update on this at all?
Author
Owner

@greg0ire commented on GitHub (May 7, 2025):

A great next step would be to provide a reproducer, preferably in the form of a functional test

@greg0ire commented on GitHub (May 7, 2025): A great next step would be to provide a reproducer, preferably in the form of [a functional test](https://github.com/doctrine/orm/blob/3.3.x/CONTRIBUTING.md#unit-tests)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7374