After upgrading drupal version to 8.3.4, I observed the following issue while doing xml decode.

Error: Recoverable fatal error: Argument 1 passed to Symfony\Component\Serializer\Encoder\SerializerAwareEncoder::setSerializer() must be an instance of Symfony\Component\Serializer\SerializerInterface, null given, called in /core/modules/serialization/src/Encoder/XmlEncoder.php on line 41 and defined in Symfony\Component\Serializer\Encoder\SerializerAwareEncoder->setSerializer() (line 29 of vendor/symfony/serializer/Encoder/SerializerAwareEncoder.php).

Comments

janmejaya created an issue. See original summary.

janmejaya’s picture

StatusFileSize
new1.47 KB

Status: Needs review » Needs work

The last submitted patch, 2: XmlEncoder_2891850.patch, failed testing. View results

janmejaya’s picture

Status: Needs work » Needs review
StatusFileSize
new1.44 KB

The path was not correct, so I modified the proper path and uploaded the patch.

Status: Needs review » Needs work

The last submitted patch, 4: XmlEncoder_path_updated_2891850.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

janmejaya’s picture

Status: Needs work » Needs review
StatusFileSize
new1.43 KB

As per code-sniffer comment updated the patch.

janmejaya’s picture

Status: Needs review » Needs work

The last submitted patch, 6: XmlEncoder_comment_12153348_2891850.patch, failed testing. View results

wim leers’s picture

This was last changed in #2685097: Fatal error: Call to a member function normalize() on a non-object in XmlEncoder when encoding into xml and there are embedded objects in the response, to fix a fatal PHP error.

It's possible this is a regression, but to determine that, we need steps to reproduce at minimum.

Finally, this is definitely not critical, because it only affects a tiny fraction of Drupal 8 sites at most.

wim leers’s picture

Status: Needs work » Postponed (maintainer needs more info)
janmejaya’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

During decode function call we need to follow the following steps to fix this issue:

setBaseEncoder(new BaseXmlEncoder());
$XmlEncoder->decode($xml_data, 'array');

So no need to modify the drupal core.

damiankloip’s picture

Ideally, you shouldn't use the XML encoder directly. It's meant to be used as a part of the serializer.

jhedstrom’s picture

I've added #2910682: Mark serializer encoders @internal to make this more clear that the encoder service shouldn't be used directly.