Fix dependency injection error for getStorage()

Created on 25 July 2024, 8 months ago
Updated 10 August 2024, 8 months ago

Problem/Motivation

The website encountered an unexpected error. Try again later.

Error: Call to a member function getStorage() on null in Drupal\media_entity_download\Plugin\Field\FieldFormatter\DownloadLinkFieldFormatter->viewElements() (line 105 of modules/contrib/media_entity_download/src/Plugin/Field/FieldFormatter/DownloadLinkFieldFormatter.php).

This error happens for download links. The issue seems to be because of a faulty dependency injection implementation. Fixed in the attached patch.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Postponed: needs info

Version

2.3

Component

Code

Created by

🇷🇴Romania biancaradu27

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

Merge Requests

Comments & Activities

  • Issue created by @biancaradu27
  • First commit to issue fork.
  • Merge request !23Fixed dependency issues → (Open) created by Unnamed author
  • Pipeline finished with Success
    8 months ago
    Total: 150s
    #233742
  • Status changed to Needs review 8 months ago
  • 🇮🇳India sarwan_verma

    I have successfully applied the patch and tested its functionality. I have also created MR! 23.
    Kindly review and verify.
    thanks.

  • 🇷🇴Romania biancaradu27

    Had to redo the patch because there was an issue with the arguments number in the constructor.

  • Status changed to Postponed: needs info 8 months ago
  • 🇨🇭Switzerland berdir Switzerland

    this isn't fault, it's a common approach for subclasses to be independent from the parent. If you get an error you might have a subclass that doesn't call parent::create().

Production build 0.71.5 2024