Skip to content

fix: avoid mime_content_type warning on wrapped streams#592

Open
olddude2 wants to merge 1 commit into
nextcloud:mainfrom
olddude2:fix/mime-content-type-stream-cast-warning
Open

fix: avoid mime_content_type warning on wrapped streams#592
olddude2 wants to merge 1 commit into
nextcloud:mainfrom
olddude2:fix/mime-content-type-stream-cast-warning

Conversation

@olddude2

Copy link
Copy Markdown

mime_content_type() requires stream_cast() support to operate on a stream resource directly. Streams returned by File::fopen() can be wrapped in Icewind\Streams\CallbackWrapper, which does not implement stream_cast(), causing a PHP warning to be logged on every preview/output-file request even though the mime type is still detected correctly.

This drains the stream into a temporary file first, then calls mime_content_type() against the file path instead. No behavior change; only removes log noise.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

mime_content_type() requires stream_cast() support to operate on a
stream resource directly. Streams returned by File::fopen() can be
wrapped in Icewind\Streams\CallbackWrapper, which does not implement
stream_cast(), causing a PHP warning to be logged on every
preview/output-file request even though the mime type is still
detected correctly.

This drains the stream into a temporary file first, then calls
mime_content_type() against the file path instead. No behavior change;
only removes log noise.

Signed-off-by: Simon Holzman <simon.holzman@verizon.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant