SecondCacheLevel association and inheritance update problem #5105

Open
opened 2026-01-22 14:58:26 +01:00 by admin · 0 comments
Owner

Originally created by @mpoiriert on GitHub (Apr 19, 2016).

Originally assigned to: @lcobucci on GitHub.

I have a entities like this (I just document the minimum needed):


/**
 * @Entity
 * @Cache("NONSTRICT_READ_WRITE")
 * @DiscriminatorColumn(name="type", type="string")
 * @DiscriminatorMap({"child" = "ChildClass"})
 */
class BaseClass
{
}

/**
 * @Entity
 * @Cache("NONSTRICT_READ_WRITE")
 */
class ChildClass extends BaseClass
{
  /**
  * @Cache("NONSTRICT_READ_WRITE")
  */
  private $associations;
}

When changing the ChildClass->associations value and persisting it the data in the cache is not removed.

Investigating I found that the Doctrine\ORM\Cache\Persister\Entity\AbstractEntityPersister is using the entityName (that will be ChildClass) but that the Doctrine\ORM\Cache\Persister\Collection\NonStrictReadWriteCachedCollectionPersister is using the $this->sourceEntity->rootEntityName (that will be BaseClass) So it doesn't clear the proper key entry.

Pretty easy to change but might be risky...

If you consider that I am on the good track I can give it a try to make the unit test for it.

Originally created by @mpoiriert on GitHub (Apr 19, 2016). Originally assigned to: @lcobucci on GitHub. I have a entities like this (I just document the minimum needed): ``` php /** * @Entity * @Cache("NONSTRICT_READ_WRITE") * @DiscriminatorColumn(name="type", type="string") * @DiscriminatorMap({"child" = "ChildClass"}) */ class BaseClass { } /** * @Entity * @Cache("NONSTRICT_READ_WRITE") */ class ChildClass extends BaseClass { /** * @Cache("NONSTRICT_READ_WRITE") */ private $associations; } ``` When changing the ChildClass->associations value and persisting it the data in the cache is not removed. Investigating I found that the **Doctrine\ORM\Cache\Persister\Entity\AbstractEntityPersister** is using the **entityName** (that will be **ChildClass**) but that the **Doctrine\ORM\Cache\Persister\Collection\NonStrictReadWriteCachedCollectionPersister** is using the **$this->sourceEntity->rootEntityName** (that will be **BaseClass**) So it doesn't clear the proper key entry. Pretty easy to change but might be risky... If you consider that I am on the good track I can give it a try to make the unit test for it.
admin added the BugDuplicate labels 2026-01-22 14:58:26 +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#5105