Opened 4 weeks ago
Last modified 4 days ago
#65870 accepted defect (bug)
wp_is_stream() should align with PHP stream handler matching
| Reported by: | jonsurrell | Owned by: | jonsurrell |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.2 |
| Component: | General | Version: | 3.5 |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
wp_is_stream() performs exact (case-sensitive) matching against the results of stream_get_wrappers(). This differs from PHP, so PHP may handle some streams that wp_is_stream() reports as false.
When matching a scheme to a registered stream wrapper, PHP will check for an exact match, then check for a lower case match of the scheme against the registered stream wrappers. This has been the behavior since 4427552 which I believe shipped with PHP 5.2 and remains largely unchanged. wp_is_stream() fails to recognize some common streams if the scheme is not lowercase:
<?php foreach ( array( 'file', 'FILE', 'fIlE' ) as $scheme ) { $f = "{$scheme}://" . php_ini_loaded_file(); echo "{$f} / is_stream: " . var_export( wp_is_stream( $f ), true ) . " / strlen: " . strlen( file_get_contents( $f ) ) . "\n"; }
file:///internal/shared/php.ini / is_stream: true / strlen: 802 FILE:///internal/shared/php.ini / is_stream: false / strlen: 802 fIlE:///internal/shared/php.ini / is_stream: false / strlen: 802
Change History (4)
This ticket was mentioned in PR #13038 on WordPress/wordpress-develop by @khokansardar.
4 weeks ago
#1
- Keywords has-patch has-unit-tests added
This ticket was mentioned in PR #13436 on WordPress/wordpress-develop by @jonsurrell.
4 days ago
#4
#WIP
Trac ticket:
## Use of AI Tools
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
wp_is_stream()reportsfalsefor stream URLs whose scheme is not lowercase, such asFILE:///path/to/file, even though PHP opens and reads them without trouble.PHP resolves a scheme by looking it up in the registered wrappers as given, then retrying once with the scheme lowercased;
wp_is_stream()only did the exact match. The patch adds the same lowercased fallback. It deliberately does not lowercase the registered wrappers, so a wrapper registered asMyStreamstays unreachable asmystream, matching PHP.The accepted set only widens, so no path that returned
truebefore can now returnfalse.Trac ticket: https://core.trac.wordpress.org/ticket/65870
## Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Reviewing PHP's stream wrapper lookup, drafting the fix, and adding regression tests. All changes were reviewed and validated by me.