Problem/Motivation
The module drupal/entity_usage includes a hardcoded assumption that the public file system uses a local stream wrapper (LocalStream). This is reflected in the assertion:
assert($publicStream instanceof LocalStream);
However, when using external file systems (such as the drupal/s3fs module for Amazon S3), the public stream wrapper implements the generic StreamWrapperInterface but does not extend LocalStream. Therefore, the assertion fails and throws an exception, making the module incompatible with setups using external file storage.
Steps to reproduce
- Set up Drupal with the drupal/s3fs module and configure the public file system to use Amazon S3 instead of the local filesystem.
- Enable the entity_usage module.
- Access a URL referencing a public file.
- Observe that the site throws an error caused by the failed assertion:
assert($publicStream instanceof LocalStream);
Proposed resolution
Modify the assertion to validate the general interface rather than the specific local implementation, ensuring compatibility with external stream wrappers like drupal/s3fs. Update the line from:
assert($publicStream instanceof LocalStream);
to
assert($publicStream instanceof StreamWrapperInterface);
This general approach ensures broader compatibility across different storage backends.
Remaining tasks
- Submit a patch or merge request with the proposed fix.
- Test the fix thoroughly, both with local and external stream wrappers (e.g., s3fs).
User interface changes
None.
API changes
None.
Data model changes
None.