Skip to content

Using annotation always resulting in writing to cache #358

Description

@paventuri

Given an annotation:

/**
 * @Annotation
 * @Target("METHOD")
 */
class MyAnnotation extends Annotation
{
    /**
     * @var string
     */
    public $name = null;

    /**
     * @var string
     */
    public $tag = null;
}

Given an aspect:

/**
     *
     * @param MethodInvocation $invocation
     *
     * @Around("@execution(MyAnnotation)")
     */
    public function aroundInvocation(MethodInvocation $invocation)
    {

        /** @var MyAnnotation $annotation */
        $annotation = $invocation->getMethod()->getAnnotation(MyAnnotation::class);
        $name = $annotation->name;
    }

The problem is that a call to $invocation->getMethod()->getAnnotation(MyAnnotation::class); results in a call to FileCacheReader::getAnnotations. Which will get the className like so: $class = $method->getDeclaringClass();

The declaring class in this case is always Class__AopProxied which is not cached. By the way, I'm using Features::PREBUILT_CACHE as I have a read-only file systems.

Error:
The directory "/var/www/html/docroot/bootstrap/cache/aspect/_annotations" is not writable. Both, the webserver and the console user need access. You can manage access rights for multiple users with "chmod +a". If your system does not support this, check out the acl package.

Is there any workaround for this issue? Thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions