Problem/Motivation
Originally reported by pfrenssen in https://www.drupal.org/project/simple_oauth/issues/3574042
Multiple classes in the module assign entity storage classes in the constructor. This can cause errors during site installation by triggering plugin discovery.
This anti-pattern is documented by Matt Glaman in https://mglaman.dev/blog/dependency-injection-anti-patterns-drupal (see "Assigning entity storage to a property instead of the entity manager.").
Proposed resolution
Store a reference to the entity type manager and fetch the storage only when it's needed. Deprecate the existing storage properties.
Issue fork simple_oauth-3579430
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
pfrenssenThanks for creating this issue!
Comment #5
pfrenssenComment #6
pfrenssenWe should for now deprecate the population of the storage handlers and not fully remove them so custom code that extends our classes keeps working. Follow the same approach as used in #3574042: Classes should not store references to the config as class properties.
Comment #7
pfrenssenIntroduced the B/C layer.
Comment #8
pfrenssenComment #10
bojan_dev commentedNice work @pfrenssen!