StreamWrapperManager Service has public methods not on interface.

Created on 3 January 2022, over 2 years ago
Updated 7 February 2023, over 1 year ago

Problem/Motivation

Currently StreamWrapperManager has addStreamWrapper, register() and unregister() documented as

   *
   * Internal use only.
   *

without the @internal flag.

These functions are necessary for Core to bootstrap however they are generally not necessary for most modules likely justifying them generally being considered internal.

However since the StreamWrapperManager is a Drupal Service it is possible to decorate with a Service Decorator. Any module wanting to decorate the StreamWrapperManager must implement these methods or core will be unable to function.

Possible reasons to Decorate the StreamWrapperManager service that I have seen are:

  • Registering a StreamWrapper for use as a supported stream for use in Managed Files but not overriding the protocol in PHP (http/https in Remote Stream Wrapper as an example)
  • Adding StreamWrappers when schemes are not known during the Compiler Pass as they require data from Config Entities (being implemented in S3FS)

With these functions not on the interface they appear (by policy) to be subject to change in minor point releases without any deprecation window making decorating the service appear 'risky'.

Steps to reproduce

See core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php

Proposed resolution

Add addStreamWrapper, register(), unregister() to a new interface.
Document they are generally not to be called and are on interface solely for Drupal Core and Service Decorators.

Remaining tasks

User interface changes

None

API changes

New interface created for existing methods.

Data model changes

None Expected.

Release notes snippet

TBD

πŸ› Bug report
Status

Needs work

Version

10.1 ✨

Component
BaseΒ  β†’

Last updated 19 minutes ago

Created by

πŸ‡ΊπŸ‡ΈUnited States cmlara

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024