Skip to content

stream_is_local(): unwrap zlib and bzip2 wrappers if needed - #23714

Open
DanielEScherzer wants to merge 4 commits into
php:masterfrom
DanielEScherzer:stream_is_local
Open

DanielEScherzer wants to merge 4 commits into
php:masterfrom
DanielEScherzer:stream_is_local

Conversation

@DanielEScherzer

@DanielEScherzer DanielEScherzer commented Sep 17, 2026

Copy link
Copy Markdown
Member

When a stream is wrapped with compress.zlib://, or compress.bzip2:// , consult the appropriate stream wrapper operations to determine if a stream is local or not.

Comment thread ext/standard/streamsfuncs.c Outdated

@bukka bukka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Nora said, this is a hack. It needs to get info from the wrapper and not doing checks by name.

Add tests to demonstrate that the `zlib:`, `compress.zlib://`, and
`compress.bzip2://` wrappers also result in `stream_is_local()` returning
`true`. This behavior will be changed in a subsequent commit.
Switch `php_stream_wrapper.is_url` from a binary flag (stored as an `int`) to
an instance of the new enum `php_stream_wrapper_is_url`, which has the cases
`STREAM_IS_URL_NEVER`, `STREAM_IS_URL_ALWAYS`, and `STREAM_IS_URL_SOMETIMES`.

Add a new optional stream wrapper operation,
`php_stream_wrapper_ops.stream_is_url`, that checks if the given path should be
considered a URL or not. This callback is required when a stream wrapper is
marked as `STREAM_IS_URL_SOMETIMES`.

Update existing stream wrappers:

- most of those are marked as not being URLs (`is_url` was 0) just updated that
field to be `STREAM_IS_URL_NEVER` and added a new NULL field to their
operations.
- all of those marked as being URLs (`is_url` was 1) just updated that field to
be `STREAM_IS_URL_ALWAYS` and added a new NULL field to their operations.
- for the zlib and bz2 wrappers, which were previously marked as never being
URLs (`is_url` was 0), set the field to `STREAM_IS_URL_SOMETIMES` and implement
the new operation to strip the `compress.zlib://` and `compress.bzip2://`
prefixes respectively and then check the underlying wrapped stream.
@DanielEScherzer

Copy link
Copy Markdown
Member Author

As Nora said, this is a hack. It needs to get info from the wrapper and not doing checks by name.

Yeah, I was trying to avoid doing large cross-cutting changes so close to the 8.6 branch, but that makes sense - done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants