Skip to content

Loading…

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

Closed
doctrinebot opened this Issue · 4 comments

1 participant

@doctrinebot

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

@doctrinebot

Comment created by jkleijn:

Confused "fix" with "affects", sorry

@doctrinebot

Comment created by romanb:

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

@doctrinebot

Comment created by jkleijn:

Cause I didn't read the caching docs?

@doctrinebot

Issue was closed with resolution "Invalid"

@doctrinebot doctrinebot added the Bug label
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.