Align wp_is_stream with PHP stream handler internals - #13436
Draft
sirreal wants to merge 6 commits into
Draft
Conversation
PHP resolves a scheme by looking it up as given, then retrying once with the scheme lowercased. wp_is_stream() only performed the exact match, so paths such as `FILE:///path/to/file` were reported as non-streams even though PHP reads them. Match the scheme as given, then fall back to a lowercased lookup. The registered wrappers are not themselves lowercased, so a wrapper registered as `MyStream` remains unreachable as `mystream`, as in PHP. Fixes #65870.
Compare wp_is_stream() with invocation of a registered PHP wrapper. Reject one-character schemes and recognize the case-sensitive data: prefix without slashes. Cover case matching, scheme syntax, and wrapper registration state. Confirmed red/green failures for one-character schemes and data: URLs. See #65870.
Replace numeric dataset keys with descriptions of the URL or path so test output identifies each case.
Keep wp_is_stream() limited to schemes followed by ://, since callers depend on that delimiter. Document the distinction between wrapper selection and opening a resource. Test built-in data handler case variants separately from replacement-wrapper selection, with PHP and file controls and allow_url_fopen handling. Confirmed the exclusion test fails before removing the special case and passes afterward. See #65870.
Keep the lowercase fallback and direct PHP case-comparison tests. Defer scheme-length changes, data URL recognition, built-in handler tests, and caller work to the dependent follow-up. The 19 stream tests fail in three cases without case fallback and pass with it. The full functions test file passes: 240 tests, 967 assertions, one skip.
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#WIP
Trac ticket:
Use of AI Tools
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.