[PR #6017] Avoid error when entityName isn't a string #9825

Closed
opened 2026-01-22 16:05:31 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/6017

State: closed
Merged: No


Previously I wasn't used the ->clear() method in the correct way. I always put the full entity object in parameter instead of the entity name. It worked before the 2.5.5 even if in fact it cleared nothing ...

With 2.5.5 a check has been added in clearIdentityMapForEntityName to verify if the given entity name exist in the entityMap.

Using isset with the entity object generated a PHP error Illegal offset type in isset or empty.

This PR aim to remove that error.

I'm not sure if this is the right way to fix that problem. I'm maybe the only person who gave the entity object as parameter to the clear function.
Maybe we should better detect if it's an object in the clear function and use the :class attribute to get the class name?

Like

public function clear($entityName = null)
{
    if (is_object($entityName)) {
        $entityName = $entityName::class;
    }
**Original Pull Request:** https://github.com/doctrine/orm/pull/6017 **State:** closed **Merged:** No --- Previously I wasn't used the `->clear()` method in the correct way. I always put the full entity object in parameter instead of the entity name. It _worked_ before the 2.5.5 even if in fact it cleared nothing ... With 2.5.5 a check has been added in `clearIdentityMapForEntityName` to verify if the given entity name exist in the entityMap. Using `isset` with the entity object generated a PHP error `Illegal offset type in isset or empty`. This PR aim to remove that error. I'm not sure if this is the right way to fix that problem. I'm maybe the only person who gave the entity object as parameter to the `clear` function. Maybe we should better detect if it's an object in the `clear` function and use the `:class` attribute to get the class name? Like ``` php public function clear($entityName = null) { if (is_object($entityName)) { $entityName = $entityName::class; } ```
admin added the pull-request label 2026-01-22 16:05:31 +01:00
admin closed this issue 2026-01-22 16:05:31 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#9825