DCOM-12: Annotation caching causes application instance mixups #419

doctrinebot opened this Issue Jul 13, 2010 · 4 comments

1 participant


Jira issue originally created by user jkleijn:

Take a look at lib/Doctrine/Common/Annotations/AnnotationReader.php:137

     * Gets the annotations applied to a class.
     * @param string|ReflectionClass $class The name or ReflectionClass of the class from which
     * the class annotations should be read.
     * @return array An array of Annotations.
    public function getClassAnnotations(ReflectionClass $class)
        $cacheKey = $class->getName() . self::$CACHE_SALT;

        // Attempt to grab data from cache
        if (($data = $this->cache->fetch($cacheKey)) !== false) {
            return $data;

        $annotations = $this->parser->parse($class->getDocComment(), 'class ' . $class->getName());
        $this->cache->save($cacheKey, $annotations, null);

        return $annotations;

It uses the class name and a static salt to create a cache key. Actually, everything in that class uses a class name to assemble a cache key.

This makes it impossible to have mulitple instances of the same application in different states. Practically: it makes it impossible to have testing and staging, or staging and production versions on the same host if they use the same type of caching (which you sort of need in a staging environment).


Comment created by jkleijn:

Confused "fix" with "affects", sorry


Comment created by romanb:

Why not just use the namespacing facilities of the cache drivers?


Comment created by jkleijn:

Cause I didn't read the caching docs?


Issue was closed with resolution "Invalid"

@doctrinebot doctrinebot added the Bug label Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment