Stringable objects are treated like "mapped" in 2.8.0 #6582

Closed
opened 2026-01-22 15:35:19 +01:00 by admin · 4 comments
Owner

Originally created by @garak on GitHub (Dec 4, 2020).

After upgrading to 2.8.0, I'm getting a lot of exceptions when I use stringable objects.
For example, using something like:

/** @var \Doctrine\ORM\EntityManagerInterface $manager */
$manager
    ->createQueryBuilder()
    ->from(MyEntity::class, 'e')
    ->select('e')
    ->where('e.foo = :foo')
    ->setParameter('foo', $anObjectConvertableToString)
    ->setMaxResults(1)
    ->getQuery()
    ->getOneOrNullResult()
;

is working in doctrine/orm 2.7, while in 2.8 raises an exception:

The class 'Namespace\AnObjectConvertableToString' was not found in the chain configured namespaces [...]

Originally created by @garak on GitHub (Dec 4, 2020). After upgrading to 2.8.0, I'm getting a lot of exceptions when I use stringable objects. For example, using something like: ```php /** @var \Doctrine\ORM\EntityManagerInterface $manager */ $manager ->createQueryBuilder() ->from(MyEntity::class, 'e') ->select('e') ->where('e.foo = :foo') ->setParameter('foo', $anObjectConvertableToString) ->setMaxResults(1) ->getQuery() ->getOneOrNullResult() ; ``` is working in doctrine/orm 2.7, while in 2.8 raises an exception: > The class 'Namespace\AnObjectConvertableToString' was not found in the chain configured namespaces [...]
admin added the BugBC Break labels 2026-01-22 15:35:19 +01:00
admin closed this issue 2026-01-22 15:35:20 +01:00
Author
Owner

@beberlei commented on GitHub (Dec 4, 2020):

@garak does $anObjectConvertableToSTring implement traversable? This 2.8 PR https://github.com/doctrine/orm/pull/8162 is changing related code you are talking about.

@beberlei commented on GitHub (Dec 4, 2020): @garak does `$anObjectConvertableToSTring` implement traversable? This 2.8 PR https://github.com/doctrine/orm/pull/8162 is changing related code you are talking about.
Author
Owner

@garak commented on GitHub (Dec 4, 2020):

No: it's just an object with a __toString() method.

@garak commented on GitHub (Dec 4, 2020): No: it's just an object with a `__toString()` method.
Author
Owner

@stof commented on GitHub (Dec 4, 2020):

Looks like the catch on 418587bc25/lib/Doctrine/ORM/AbstractQuery.php (L450-L454) does not work properly anymore

@stof commented on GitHub (Dec 4, 2020): Looks like the catch on https://github.com/doctrine/orm/blob/418587bc25c107f16b53ae67a6ef8589408aff6c/lib/Doctrine/ORM/AbstractQuery.php#L450-L454 does not work properly anymore
Author
Owner

@alex-dev commented on GitHub (Dec 4, 2020):

Doctrine\ORM\Mapping\MappingException as ORMMappingException is caught, Doctrine\Persistence\Mapping\MappingException is thrown in 2.8.

@alex-dev commented on GitHub (Dec 4, 2020): Doctrine\ORM\Mapping\MappingException as ORMMappingException is caught, Doctrine\Persistence\Mapping\MappingException is thrown in 2.8.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6582