Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1909

Getting Fatal error Call to undefined method Doctrine\ORM\Mapping\ClassMetadata::getSqlExecutor()

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.2
    • Fix Version/s: 2.2.3
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:

      Description

      ( ! ) Fatal error: Call to undefined method Doctrine\ORM\Mapping\ClassMetadata::getSqlExecutor() in /home/www/scms/library/Doctrine/ORM/Query.php on line 241
      Call Stack
      #	Time	Memory	Function	Location
      1	0.0000	327100	{main}( )	../index.php:0
      2	0.1485	4174724	Zend_Application->run( )	../index.php:47
      3	0.1485	4174724	Zend_Application_Bootstrap_Bootstrap->run( )	../Application.php:366
      4	0.1486	4174796	Zend_Controller_Front->dispatch( ???, ??? )	../Bootstrap.php:97
      5	0.1545	4488224	Zend_Controller_Router_Rewrite->route( object(Zend_Controller_Request_Http)[333] )	../Front.php:911
      6	0.1550	4488968	SCMS_Controller_Router_Route->match( string(6), ??? )	../Rewrite.php:398
      7	0.1567	4570028	Doctrine\ORM\AbstractQuery->getOneOrNullResult( long )	../Route.php:72
      8	0.1567	4570192	Doctrine\ORM\AbstractQuery->execute( array(0), long )	../AbstractQuery.php:571
      9	0.1567	4570660	Doctrine\ORM\Query->_doExecute( )	../AbstractQuery.php:733
      Variables in local scope (#9)
      
      $executor =
      
      	Undefined
      
      $paramMappings =
      
      	Undefined
      
      $sqlParams =
      
      	Undefined
      
      $types =
      
      	Undefined
      
      

      error appears out of the blue, after a few refreshes it disappears, but this happens constantly.

        Activity

        Justinas created issue -
        Justinas made changes -
        Field Original Value New Value
        Affects Version/s 2.2.2 [ 10195 ]
        Fix Version/s 2.2.2 [ 10195 ]
        Hide
        Marco Pivetta added a comment - - edited

        Can you try namespacing your caches (metadata/query/results) and see if the problem persists?
        Also, it would be interesting to see your bootstrap configuration...

        Show
        Marco Pivetta added a comment - - edited Can you try namespacing your caches (metadata/query/results) and see if the problem persists? Also, it would be interesting to see your bootstrap configuration...
        Hide
        Benjamin Eberlei added a comment -

        We need the complete bootstrap configuratino and options.

        Show
        Benjamin Eberlei added a comment - We need the complete bootstrap configuratino and options.
        Benjamin Eberlei made changes -
        Workflow jira [ 13822 ] jira-feedback [ 14090 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback [ 14090 ] jira-feedback2 [ 15954 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 15954 ] jira-feedback3 [ 18201 ]
        Hide
        Justinas added a comment -

        DoctrineCache.php is a controller plugin that runs first and initializes doctrine cache usually memcache servers
        options.ini contains all configuration options for doctrine

        Bisna initializes Doctrine based on options and integrates it into ZF

        as you can see all caches are namespaced, and i'm currently the only one using system locally so no cache conflicts should occur even without namespaces

        Show
        Justinas added a comment - DoctrineCache.php is a controller plugin that runs first and initializes doctrine cache usually memcache servers options.ini contains all configuration options for doctrine Bisna initializes Doctrine based on options and integrates it into ZF as you can see all caches are namespaced, and i'm currently the only one using system locally so no cache conflicts should occur even without namespaces
        Justinas made changes -
        Attachment DoctrineCache.php [ 11202 ]
        Attachment options.ini [ 11203 ]
        Attachment Bisna.zip [ 11204 ]
        Hide
        Benjamin Eberlei added a comment -

        Can you show one of your controller actions/model services where this error occurs, explicitly the code that generates the ResultCache keys.

        Show
        Benjamin Eberlei added a comment - Can you show one of your controller actions/model services where this error occurs, explicitly the code that generates the ResultCache keys.
        Hide
        Justinas added a comment -
        if ($em instanceof \Doctrine\ORM\EntityManager) {
        			//search for matching vanity urls from most accurate to least accurate
        			//matching full slug first /tv/samsung/lcd then /tv/samsung, and then /tv
        			foreach ($urls as $possible_match) {
        				/* @var $q Doctrine\ORM\Query */
        				$q = $em->createQuery('SELECT r
        				FROM SCMS\Entity\Route r
        				WHERE r.full_slug = :slug');
        				$q->setMaxResults(1)
        						->setParameter('slug', $possible_match)
        						->useResultCache(true, \SCMS\DbCache::TTL_ROUTE, $possible_match);
        
        				$result = $q->getOneOrNullResult(\Doctrine\ORM\Query::HYDRATE_ARRAY);
        
        Show
        Justinas added a comment - if ($em instanceof \Doctrine\ORM\EntityManager) { //search for matching vanity urls from most accurate to least accurate //matching full slug first /tv/samsung/lcd then /tv/samsung, and then /tv foreach ($urls as $possible_match) { /* @var $q Doctrine\ORM\Query */ $q = $em->createQuery('SELECT r FROM SCMS\Entity\Route r WHERE r.full_slug = :slug'); $q->setMaxResults(1) ->setParameter('slug', $possible_match) ->useResultCache(true, \SCMS\DbCache::TTL_ROUTE, $possible_match); $result = $q->getOneOrNullResult(\Doctrine\ORM\Query::HYDRATE_ARRAY);
        Hide
        Marco Pivetta added a comment -

        You should definitely namespace your cache (with something like Doctrine\Common\Cache\ApcCache#setNamespace() for example), since you're manually defining your cache key here...

        Is the explicit usage of the cache ID intended?

        Benjamin Eberlei, should the fetched cache items be checked for their type?

        Show
        Marco Pivetta added a comment - You should definitely namespace your cache (with something like Doctrine\Common\Cache\ApcCache#setNamespace() for example), since you're manually defining your cache key here... Is the explicit usage of the cache ID intended? Benjamin Eberlei , should the fetched cache items be checked for their type?
        Hide
        Benjamin Eberlei added a comment -

        What are the contents of $urls and $possible_match? You should namespace them even further in your code:

        $q->useResultCache(true, \SCMS\DbCache::TTL_ROUTE, "my_query_type_something_" . $possible_match);
        
        Show
        Benjamin Eberlei added a comment - What are the contents of $urls and $possible_match? You should namespace them even further in your code: $q->useResultCache( true , \SCMS\DbCache::TTL_ROUTE, "my_query_type_something_" . $possible_match);
        Hide
        Benjamin Eberlei added a comment -

        This isn't related to the result cache, but to the query cache though i just realized. However i don't see any way this is possible, the DQL Query Cache key is generated as a hash, the Metadata cache entry is generated using the ClassName as key. I don't udnerstand how the Metadata could end up in a Query Cache key.

        @ocramius As a fix, in AbstractQuery and ClassMetadataFactory, we should check if the return value is really instanceof ClassMetadata or ParserResult. And if that happens throw an error. Also we should prefix the metadata and DQL queries ourself.

        Show
        Benjamin Eberlei added a comment - This isn't related to the result cache, but to the query cache though i just realized. However i don't see any way this is possible, the DQL Query Cache key is generated as a hash, the Metadata cache entry is generated using the ClassName as key. I don't udnerstand how the Metadata could end up in a Query Cache key. @ocramius As a fix, in AbstractQuery and ClassMetadataFactory, we should check if the return value is really instanceof ClassMetadata or ParserResult. And if that happens throw an error. Also we should prefix the metadata and DQL queries ourself.
        Hide
        Justinas added a comment -

        $urls is an array of URIs array('/tv/samsung/lcd', '/tv/samsung', '/tv');
        $possible_match is the value of array ex.: '/tv/samsung/lcd'

        i'm setting the namespace in the configuration, and providing a unique id for each result cache. the documentation isn't clear
        is namespace prefixed automatically if you set your cache id or is namespace ignored if you set cache id yourself.
        so i always assumed that namespace is prefixed automatically, and that you have to set cacheId yourself for same query with different parameters, so that query searching for '/tv/samsung' would not return the same result as searching for '/tv';

        Show
        Justinas added a comment - $urls is an array of URIs array('/tv/samsung/lcd', '/tv/samsung', '/tv'); $possible_match is the value of array ex.: '/tv/samsung/lcd' i'm setting the namespace in the configuration, and providing a unique id for each result cache. the documentation isn't clear is namespace prefixed automatically if you set your cache id or is namespace ignored if you set cache id yourself. so i always assumed that namespace is prefixed automatically, and that you have to set cacheId yourself for same query with different parameters, so that query searching for '/tv/samsung' would not return the same result as searching for '/tv';
        Hide
        Benjamin Eberlei added a comment -

        can you try setting different namespace for Query and Metadata cache? They seem to use the same prefix. Only the Result cache uses its own prefix.

        Show
        Benjamin Eberlei added a comment - can you try setting different namespace for Query and Metadata cache? They seem to use the same prefix. Only the Result cache uses its own prefix.
        Hide
        Marco Pivetta added a comment -

        Justinas, setting different caches for query, results and metadata allows you to have, as an example, 3 caches writing/reading from APC. If you set a namespace for those caches, those won't collide (everything is handled transparently).

        Anyway Benjamin Eberlei is correct when he states that this shouldn't happen here. Even if your approach isn't correct (you don't need to explicitly set any cache key here, plus you should be using namespaced caches) the issue seems to be valid...

        Does this happen also with a clean cache?

        Show
        Marco Pivetta added a comment - Justinas , setting different caches for query, results and metadata allows you to have, as an example, 3 caches writing/reading from APC. If you set a namespace for those caches, those won't collide (everything is handled transparently). Anyway Benjamin Eberlei is correct when he states that this shouldn't happen here. Even if your approach isn't correct (you don't need to explicitly set any cache key here, plus you should be using namespaced caches) the issue seems to be valid... Does this happen also with a clean cache?
        Hide
        Justinas added a comment -

        i'm not sure, about the clean cache, it just doesn't happen all the time so it's hard to check. If i remember correctly i flushed the cache, and the error appeared, after a few refreshes it disappeared, without flushing cache. it sorta appears and disappears from time to time.

        even if i don't set the namespace for my caches i have a local memcache, so no cache collision from other projects shouldn't occur

        Show
        Justinas added a comment - i'm not sure, about the clean cache, it just doesn't happen all the time so it's hard to check. If i remember correctly i flushed the cache, and the error appeared, after a few refreshes it disappeared, without flushing cache. it sorta appears and disappears from time to time. even if i don't set the namespace for my caches i have a local memcache, so no cache collision from other projects shouldn't occur
        Hide
        Benjamin Eberlei added a comment -

        Added a guard to avoid this problem. Its not a real fix, but i cannot come up with the a way to reproduce the problem that you have exactly.

        Show
        Benjamin Eberlei added a comment - Added a guard to avoid this problem. Its not a real fix, but i cannot come up with the a way to reproduce the problem that you have exactly.
        Benjamin Eberlei made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.2.3 [ 10196 ]
        Resolution Fixed [ 1 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-1909, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Justinas
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: