Attempted to call an undefined method named "storeEntityCache" of class "BasicEntityPersister" #6742

Open
opened 2026-01-22 15:37:51 +01:00 by admin · 2 comments
Owner

Originally created by @peter-gribanov on GitHub (Jun 3, 2021).

Very strange bug after recent update.

Error at this line in AbstractEntityPersister.

The method UnitOfWork::getEntityPersister() return Doctrine\ORM\Persisters\Entity\EntityPersister, which does not support storeEntityCache() method.

Stack Trace

Symfony\Component\ErrorHandler\Error\UndefinedMethodError:
Attempted to call an undefined method named "storeEntityCache" of class "Doctrine\ORM\Persisters\Entity\BasicEntityPersister".

  at vendor/doctrine/orm/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php:260
  at Doctrine\ORM\Cache\Persister\Entity\AbstractEntityPersister->storeJoinedAssociations(object(Questionnaire))
     (vendor/doctrine/orm/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php:466)
  at Doctrine\ORM\Cache\Persister\Entity\AbstractEntityPersister->loadById(array('id' => '1'))
     (vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:485)
  at Doctrine\ORM\EntityManager->find('Questionnaire', array(), null, null)
     (vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php:190)
  at Doctrine\ORM\EntityRepository->find('1')
     (vendor/sensio/framework-extra-bundle/src/Request/ParamConverter/DoctrineParamConverter.php:142)
  at Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\DoctrineParamConverter->find('Questionnaire', object(Request), array('entity_manager' => null, 'exclude' => array(), 'mapping' => array(), 'strip_null' => false, 'expr' => null, 'id' => null, 'repository_method' => null, 'map_method_signature' => false, 'evict_cache' => false), 'questionnaire')
     (vendor/sensio/framework-extra-bundle/src/Request/ParamConverter/DoctrineParamConverter.php:91)
  at Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\DoctrineParamConverter->apply(object(Request), object(ParamConverter))
     (vendor/sensio/framework-extra-bundle/src/Request/ParamConverter/ParamConverterManager.php:84)
  at Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterManager->applyConverter(object(Request), object(ParamConverter))
     (vendor/sensio/framework-extra-bundle/src/Request/ParamConverter/ParamConverterManager.php:48)
  at Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterManager->apply(object(Request), array('contest' => object(Entity), 'questionnaire' => object(ParamConverter)))
     (vendor/sensio/framework-extra-bundle/src/EventListener/ParamConverterListener.php:72)
  at Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener->onKernelController(object(ControllerEvent), 'kernel.controller', object(TraceableEventDispatcher))
     (vendor/symfony/event-dispatcher/Debug/WrappedListener.php:126)
  at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(ControllerEvent), 'kernel.controller', object(TraceableEventDispatcher))
     (vendor/symfony/event-dispatcher/EventDispatcher.php:264)
  at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.controller', object(ControllerEvent))
     (vendor/symfony/event-dispatcher/EventDispatcher.php:239)
  at Symfony\Component\EventDispatcher\EventDispatcher->callListeners(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.controller', object(ControllerEvent))
     (vendor/symfony/event-dispatcher/EventDispatcher.php:73)
  at Symfony\Component\EventDispatcher\EventDispatcher->dispatch(object(ControllerEvent), 'kernel.controller')
     (vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:168)
  at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch(object(ControllerEvent), 'kernel.controller')
     (vendor/symfony/http-kernel/HttpKernel.php:146)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:80)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:201)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request), 1, true)
     (src/Kernel.php:60)
  at Kernel->handle(object(Request))
     (web/index.php:43)
$ composer show doctrine/*
doctrine/annotations                1.13.1 Docblock Annotations Parser
doctrine/cache                      1.11.3 PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as red...
doctrine/collections                1.6.7  PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.
doctrine/common                     3.1.2  PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects ...
doctrine/dbal                       2.13.1 Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and manag...
doctrine/deprecations               v0.5.3 A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all depreca...
doctrine/doctrine-bundle            2.3.2  Symfony DoctrineBundle
doctrine/doctrine-migrations-bundle 3.1.1  Symfony DoctrineMigrationsBundle
doctrine/event-manager              1.1.1  The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine p...
doctrine/inflector                  2.0.3  PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercas...
doctrine/instantiator               1.4.0  A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                      1.2.1  PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
doctrine/migrations                 3.1.2  PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL...
doctrine/orm                        2.9.2  Object-Relational-Mapper for PHP
doctrine/persistence                2.2.1  The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine ...
doctrine/sql-formatter              1.1.1  a PHP SQL highlighting library
Originally created by @peter-gribanov on GitHub (Jun 3, 2021). Very strange bug after recent update. Error at [this line](https://github.com/doctrine/orm/blob/2.9.x/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php#L260) in AbstractEntityPersister. The method `UnitOfWork::getEntityPersister()` return `Doctrine\ORM\Persisters\Entity\EntityPersister`, which does not support `storeEntityCache()` method. Stack Trace ``` Symfony\Component\ErrorHandler\Error\UndefinedMethodError: Attempted to call an undefined method named "storeEntityCache" of class "Doctrine\ORM\Persisters\Entity\BasicEntityPersister". at vendor/doctrine/orm/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php:260 at Doctrine\ORM\Cache\Persister\Entity\AbstractEntityPersister->storeJoinedAssociations(object(Questionnaire)) (vendor/doctrine/orm/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php:466) at Doctrine\ORM\Cache\Persister\Entity\AbstractEntityPersister->loadById(array('id' => '1')) (vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:485) at Doctrine\ORM\EntityManager->find('Questionnaire', array(), null, null) (vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php:190) at Doctrine\ORM\EntityRepository->find('1') (vendor/sensio/framework-extra-bundle/src/Request/ParamConverter/DoctrineParamConverter.php:142) at Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\DoctrineParamConverter->find('Questionnaire', object(Request), array('entity_manager' => null, 'exclude' => array(), 'mapping' => array(), 'strip_null' => false, 'expr' => null, 'id' => null, 'repository_method' => null, 'map_method_signature' => false, 'evict_cache' => false), 'questionnaire') (vendor/sensio/framework-extra-bundle/src/Request/ParamConverter/DoctrineParamConverter.php:91) at Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\DoctrineParamConverter->apply(object(Request), object(ParamConverter)) (vendor/sensio/framework-extra-bundle/src/Request/ParamConverter/ParamConverterManager.php:84) at Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterManager->applyConverter(object(Request), object(ParamConverter)) (vendor/sensio/framework-extra-bundle/src/Request/ParamConverter/ParamConverterManager.php:48) at Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterManager->apply(object(Request), array('contest' => object(Entity), 'questionnaire' => object(ParamConverter))) (vendor/sensio/framework-extra-bundle/src/EventListener/ParamConverterListener.php:72) at Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener->onKernelController(object(ControllerEvent), 'kernel.controller', object(TraceableEventDispatcher)) (vendor/symfony/event-dispatcher/Debug/WrappedListener.php:126) at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(ControllerEvent), 'kernel.controller', object(TraceableEventDispatcher)) (vendor/symfony/event-dispatcher/EventDispatcher.php:264) at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.controller', object(ControllerEvent)) (vendor/symfony/event-dispatcher/EventDispatcher.php:239) at Symfony\Component\EventDispatcher\EventDispatcher->callListeners(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.controller', object(ControllerEvent)) (vendor/symfony/event-dispatcher/EventDispatcher.php:73) at Symfony\Component\EventDispatcher\EventDispatcher->dispatch(object(ControllerEvent), 'kernel.controller') (vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:168) at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch(object(ControllerEvent), 'kernel.controller') (vendor/symfony/http-kernel/HttpKernel.php:146) at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1) (vendor/symfony/http-kernel/HttpKernel.php:80) at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true) (vendor/symfony/http-kernel/Kernel.php:201) at Symfony\Component\HttpKernel\Kernel->handle(object(Request), 1, true) (src/Kernel.php:60) at Kernel->handle(object(Request)) (web/index.php:43) ``` ``` $ composer show doctrine/* doctrine/annotations 1.13.1 Docblock Annotations Parser doctrine/cache 1.11.3 PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as red... doctrine/collections 1.6.7 PHP Doctrine Collections library that adds additional functionality on top of PHP arrays. doctrine/common 3.1.2 PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects ... doctrine/dbal 2.13.1 Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and manag... doctrine/deprecations v0.5.3 A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all depreca... doctrine/doctrine-bundle 2.3.2 Symfony DoctrineBundle doctrine/doctrine-migrations-bundle 3.1.1 Symfony DoctrineMigrationsBundle doctrine/event-manager 1.1.1 The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine p... doctrine/inflector 2.0.3 PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercas... doctrine/instantiator 1.4.0 A small, lightweight utility to instantiate objects in PHP without invoking their constructors doctrine/lexer 1.2.1 PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers. doctrine/migrations 3.1.2 PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL... doctrine/orm 2.9.2 Object-Relational-Mapper for PHP doctrine/persistence 2.2.1 The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine ... doctrine/sql-formatter 1.1.1 a PHP SQL highlighting library ```
Author
Owner

@peter-gribanov commented on GitHub (Jun 3, 2021):

The problem has been resolved. The reason turned out to be in the incorrectly configured second level cache.

doctrine:
    orm:
        entity_managers:
            default:
                second_level_cache:
                    regions:
                        questionnaire_region:
                            lifetime: 86400
                            cache_driver:
                                type: pool
                                id: doctrine_second_level # this service has been renamed
@peter-gribanov commented on GitHub (Jun 3, 2021): The problem has been resolved. The reason turned out to be in the incorrectly configured second level cache. ```yaml doctrine: orm: entity_managers: default: second_level_cache: regions: questionnaire_region: lifetime: 86400 cache_driver: type: pool id: doctrine_second_level # this service has been renamed ```
Author
Owner

@peter-gribanov commented on GitHub (Jun 4, 2021):

Another problem turned out to be that i specified the caching of a related entity for which the caching region was not configured.

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Table(name="questionnaire")
 * @ORM\Entity
 * @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="questionnaire_region")
 */
class Questionnaire
{
    /**
     * @ORM\Cache(usage="NONSTRICT_READ_WRITE") # need remove this line
     * @ORM\OneToOne(targetEntity="Family", fetch="EAGER")
     * @ORM\JoinColumn(name="family_id", referencedColumnName="id", nullable=false)
     *
     * @var Family
     */
    private Family $family;

   // ...

}
use Doctrine\ORM\Mapping as ORM;

/**
 * Caching not configured
 *
 * @ORM\Table(name="family")
 * @ORM\Entity
 */
class Family
{
   // ...
}

But there is still a problem with the fact that a method is called which is not in the interface. This error is not informative at all. I spent 2 days trying to find the problem.

@peter-gribanov commented on GitHub (Jun 4, 2021): Another problem turned out to be that i specified the caching of a related entity for which the caching region was not configured. ```php use Doctrine\ORM\Mapping as ORM; /** * @ORM\Table(name="questionnaire") * @ORM\Entity * @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="questionnaire_region") */ class Questionnaire { /** * @ORM\Cache(usage="NONSTRICT_READ_WRITE") # need remove this line * @ORM\OneToOne(targetEntity="Family", fetch="EAGER") * @ORM\JoinColumn(name="family_id", referencedColumnName="id", nullable=false) * * @var Family */ private Family $family; // ... } ``` ```php use Doctrine\ORM\Mapping as ORM; /** * Caching not configured * * @ORM\Table(name="family") * @ORM\Entity */ class Family { // ... } ``` But there is still a problem with the fact that a method is called which is not in the interface. This error is not informative at all. I spent 2 days trying to find the problem.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6742