symfony: [Cache] Failed to save key of type array

Symfony version(s) affected

5.4.0-BETA3

Description

When testing SF 5.4, the following warning occurs on entities with Assert annotations and PhpFilesAdapter cache.

Failed to save key "App%5CEntity%5CPartner%24name" of type array: Cache key "App%5CEntity%5CPartner%24name" has non-serializable "array" value.

How to reproduce

class Partner
{
    /**
     * @var int
     *
     * @ORM\Column(name="id_partner", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $idPartner;

    /**
     * @var string
     *
     * @ORM\Column(name="name", type="string", length=50)
     * @Assert\NotBlank
     * @Assert\Length(
     *     min=2,
     *     max=50,
     *     minMessage="partner.name.min_size",
     *     maxMessage="partner.name.max_size"
     * )
     */
    private $name;
...
}

Possible Solution

No response

Additional Context

[
  "key" => "App%5CEntity%5CPartner%24name"
  "exception" => Symfony\Component\Cache\Exception\InvalidArgumentException {#3436 ▼
    #message: "Cache key "App%5CEntity%5CPartner%24name" has non-serializable "array" value."
    #code: 0
    #file: "/var/www/morningcroissant/symfony/vendor/symfony/cache/Adapter/PhpFilesAdapter.php"
    #line: 229
    -previous: ErrorException {#3429 …}
    trace: {▶}
  }
  "cache-adapter" => "Symfony\Component\Cache\Adapter\PhpFilesAdapter"
]

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 23 (23 by maintainers)

Commits related to this issue

Most upvoted comments

OK, I now am able to reproduce. I need to run bin/console c:c --no-warmup before refreshing the browser.

Same with this, no issue: PHP 7.3.31-2+ubuntu20.04.1+deb.sury.org+1 (cli) (built: Oct 22 2021 12:34:45) ( NTS )