Skip to content

The StreamWrapper class is currently unusable without the bucket #1137

Closed
@fgm

Description

@fgm

Bug Report

Context: I am implementing GridFS support in Drupal 10.

For that purpose, I created a stream_wrapper of our own, and implemented a first rough version using the GridFS Bucket. However, I noticed that the Bucket actually relies on a fully functional existing stream wrapper for the gridfs scheme, meaning I was implementing a stream wrapper on top of the Bucket construction using an existing stream wrapper, which means lot of useless wrapping and unwrapping.

I then looked for a way to use the gridfs stream wrapper directly, but in the current implementation, it seems there is no way to use this stream wrapper directly unless passing an explicit $context parameter to fopen() calls, which basically removes most of the interest of this abstraction.

Environment

Environment is not relevant here, as the issue is with the API shape, not its interaction with the extension and servers.

Test Script

n.a.

Expected and Actual Behavior

The expected behavior would be to have the StreamWrapper be aware of the relevant Database, obviating the need for wrapper users to pass a context, although that could still be done to override that default.

Given the lack of parameters on stream wrapper classes, this probably means setting the database as a static property on the StreamWrapper class. From there, operations could still query properties from the context, which the Bucket could still pass, and fallback to these defaults when not available.

It would allow clients not to use the Bucket, and just register the StreamWrapper and add their Database information as a static property on that class before the first use of the wrapper.

Debug Log

n.a.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions