PHP Fatal error: Declaration of Drupal\\pdf_serialization\\En coder\\PdfEncoder::encode not compatible

Created on 6 October 2023, 9 months ago
Updated 11 April 2024, 3 months ago

After the latest site update I got this Fatal error in my logs:

AH01071: Got error 'PHP message: PHP Fatal error: Declaration of Drupal\\pdf_serialization\\En
coder\\PdfEncoder::encode(mixed $data, string $format, array $context = []): string must be compatible with Symfony\\Component\\Serializer\\Encoder\\EncoderInterface::encode($data, $format, array $context = [])
in /home/deventerhuisgenoten/drupal/web/modules/contrib/pdf_serialization/src/Encoder/PdfEncoder.php on line 66'

This prevents my site from loading. Also happens after downgrade of the. Likely a change in the latest Symfony Serializer.

🐛 Bug report
Status

Needs review

Version

2.2

Component

Code

Created by

🇳🇱Netherlands jos_s

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jos_s
  • Assigned to Shreya_98
  • @shreya_th opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review 9 months ago
  • 🇮🇳India Shreya_98

    Hi @jos_s,
    I have fixed this issue and also created MR for this issue i.e. "PHP Fatal error: Declaration of Drupal\\pdf_serialization\\En coder\\PdfEncoder::encode not compatible" in PdfEncoder.php file. Kindly review the changes.

  • 🇳🇱Netherlands jos_s

    Hi Shreya_th,

    Sorry for the delay, but I have now reviewed your changes. There is still an fatal error but now with a different message:

    Got error 'PHP message: PHP Fatal error: Class Drupal\\pdf_serialization\\Encoder\\PdfEncoder contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Symfony\\Component\\Serializer\\Normalizer\\NormalizerInterface::supportsNormalization) in /home/*****/drupal/web/modules/contrib/pdf_serialization/src/Encoder/PdfEncoder.php on line 14'

    I hope this helps.

  • 🇮🇳India Shreya_98

    Thanks for responding @jos_s , I'm trying to solve this once done i will raise MR for this issue too.

  • First commit to issue fork.
  • @steveoriol opened merge request.
  • 🇳🇱Netherlands jos_s

    I can confirm that the error message disappear with the patch in #7. Thanks for solving this!

  • 🇬🇧United Kingdom keiron

    The patch in 7 worked for me too! Thanks!

  • 🇪🇸Spain programeta

    The patch #7 also worked for me! Thanks!

  • 🇮🇳India sourabhutani

    I can confirm that the error got fixed with the patch in #7. Thanks for solving this!

Production build 0.69.0 2024