Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DDC-1909: Getting Fatal error Call to undefined method Doctrine\ORM\Mapping\ClassMetadata::getSqlExecutor() #2576

Closed
doctrinebot opened this issue Jul 5, 2012 · 15 comments
Assignees
Labels
Milestone

Comments

@doctrinebot
Copy link

Jira issue originally created by user gamesh:

@doctrinebot
Copy link
Author

Comment created by @Ocramius:

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...

@doctrinebot
Copy link
Author

Comment created by @beberlei:

We need the complete bootstrap configuratino and options.

@doctrinebot
Copy link
Author

Comment created by gamesh:

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

@doctrinebot
Copy link
Author

Comment created by @beberlei:

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

@doctrinebot
Copy link
Author

Comment created by gamesh:

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);

@doctrinebot
Copy link
Author

Comment created by @Ocramius:

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?

[~beberlei], should the fetched cache items be checked for their type?

@doctrinebot
Copy link
Author

Comment created by @beberlei:

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);

@doctrinebot
Copy link
Author

Comment created by @beberlei:

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.

@doctrinebot
Copy link
Author

Comment created by gamesh:

$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';

@doctrinebot
Copy link
Author

Comment created by @beberlei:

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.

@doctrinebot
Copy link
Author

Comment created by @Ocramius:

[gamesh], 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 [beberlei] 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?

@doctrinebot
Copy link
Author

Comment created by gamesh:

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

@doctrinebot
Copy link
Author

Comment created by @beberlei:

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.

@doctrinebot
Copy link
Author

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added this to the 2.2.3 milestone Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
@doctrinebot
Copy link
Author

Imported 1 attachments from Jira into https://gist.github.com/6f33fc356cc1fd5c935a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants