Try to search your question here, if you can't find : Ask Any Question Now ?

Cache key contains reserved characters {}()/@: anonymous class caching problem. Symfony 4.2.11

HomeCategory: stackoverflowCache key contains reserved characters {}()/@: anonymous class caching problem. Symfony 4.2.11
Avatarbhawya asked 1 week ago

I got this error in log files after I executed cache:warmup on production.

[2019-10-05 16:30:34] request.CRITICAL: Uncaught PHP Exception SymfonyComponentCacheExceptionInvalidArgumentException: "Cache key "@anonymous" contains reserved characters {}()/@:" at /vendor/symfony/cache/CacheItem.php line 175 {"exception":"[object] (Symfony\Component\Cache\Exception\InvalidArgumentException(code: 0): Cache key "class@anonymousu0000/var/www/litshare/symfony/src/Dto/Output/BookDto.php0x7fbea74011c1" contains reserved characters {}()/\@: at /var/www/litshare/symfony/vendor/symfony/cache/CacheItem.php:175)"} []

The only thing that worked was not using anonymous class. I found out that this error should be resolved in Symfony 4.2.5 by this issue.

This code fails.

class BookDto
{
    public $author;

    public function __construct()
    {
        $this->author = new class {
            public $id;
            public $name;
            public $birthDate;
        };
    }
}

This one does not.

class BookDto
{
    public $author;

    public function __construct()
    {
        $this->author = new Author();
    }
}

class Author
{
  public $id;
  public $name;
  public $birthDate;
}
1 Answers
Best Answer
Avatarnaveen answered 1 week ago
Your Answer

4 + 10 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com