SvgImageUrlFormatter parent construct missing arguments 10 needed 9 passed.

Created on 21 September 2023, 9 months ago
Updated 13 October 2023, 8 months ago

Problem/Motivation

After upgrading to D10 and svg_image to 3.0.1 I was getting a below mentioned error
Too few arguments to function Drupal\image\Plugin\Field\FieldFormatter\ImageUrlFormatter::__construct(), 9 passed in /var/www/html/docroot/modules/contrib/svg_image/src/Plugin/Field/FieldFormatter/SvgImageUrlFormatter.php on line 41

Steps to reproduce

Step 1. On D10 install and enable svi_image 3.0.1 version module.
Step 2. Create a view and a svg filed with image_url field formatter.
Step 3. Visit the view or you may face problem even while adding field with a field formatter set to image_url while create the view it self.

Proposed resolution

It was found that to the parent constructor one argument FileUrlGeneratorInterface $file_url_generator was missed, hence added that argument and it resolved the issue.

🐛 Bug report
Status

Closed: duplicate

Version

3.0

Component

Code

Created by

🇮🇳India tdnshah

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

Comments & Activities

  • Issue created by @tdnshah
  • @tdnshah opened merge request.
  • 🇮🇳India sandipta

    Can we use a different pattern here to avoid dependency on upstream dependencies. Please check out https://www.hashbangcode.com/article/drupal-9-extending-drupal-base-clas....

  • 🇮🇳India sandipta

    Please review the MR

  • 🇮🇳India tdnshah

    Reviewed this and the implementation is not working and needs some more understanding on to to implement this hence rerolling the last update to version 1.
    @sandipta I would be fine test locally if the implementation is working before update the patch or asking for review, as the implementation is also not considering all the steps mentioned the attached article link, also try to create a new issue fork and raise the PR so that anyone using the working patch via git link do not get impacted.

    Thanks

  • Status changed to Closed: duplicate 8 months ago
  • 🇦🇺Australia silverham

    Closing this issue in favour of the orginal issue 🐛 SvgImageUrlFormatter parent construct wrong order Needs review where the newly attached patch fixes both issues buy using the suggestion (thanks!) to not override __construct() method but also reuse the parent create() method, then assign property after object creation so it will be compatible with future releases.

Production build 0.69.0 2024