Deserializing an Xml file into an Object can cause Cache key "p@triggers" contains reserved characters {}()/\@:
#29293
Labels
8000
Cache key "p@triggers" contains reserved characters {}()/\@:
#29293
Symfony version(s) affected: 4.1.7, 4.1.5 (Serializer Component)
Description
CacheItem throws an Error:
Cache key "p@triggers" contains reserved characters {}()/\@:
when using the Serializer Servicesdeserialize
Method in combination with ObjectNormalizer and XmlEncoder (by passing an XML File and an Object to normalize, see Reproducer below)This seems to happen when attributes are set on the xml "root" node.
How to reproduce
composer install
to load depsbin/console app:xml norootattributes.xml
bin/console app:xml rootattributes.xml
Command 1. just outputs some data.
Command 2. Fails with
Cache key "p@triggers" contains reserved characters {}()/\@:
You can work around the issue by replacing
$this->serializer = $serializer;
in\App\Command\XmlCommand
with$this->serializer = new Serializer([new ObjectNormalizer()], [new XmlEncoder()]);
The reason this works is probably because no "Caching" happens for the deserialize process, at least not in a way that it triggers the CacheItem.
Additional context
You can open the public folder where both test files reside, the only difference between them is that the root node in
rootattributes.xml
has an attribute.There has been another ticket with a similar error message, but I think the cause there was different altogether (#26313)
The text was updated successfully, but these errors were encountered: