MediaHelper should not perform loading & logic in its constructor

Created on 24 June 2024, 5 months ago

Problem/Motivation

As outlined in this blog post it's problematic to perform logic and loading in a constructor, and in particular in a service that is always initialized in Drupal.

The MediaHelper service currently does load a configuration object in its constructor, and this should be changed.

Proposed resolution

There are a few options. One would be to move the logic currently performed in the constructor into other helper method(s). Another would be to make media_helper a lazy service.

Either approach would likely have consequences for any code extending the MediaHelper class, but that probably can't be helped when solving this.

Remaining tasks

Decide on an approach to moving the logic currently in the constructor.
Implement it.

API changes

TBD

πŸ“Œ Task
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bvoynick

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

Comments & Activities

Production build 0.71.5 2024