Streams: Return early from wp_is_stream() for paths that aren't streams.

Some versions of PHP appear to have a memory leak that is occasionally triggered by calling `stream_get_wrappers()`. In order to avoid calling this, we can return early from `wp_is_stream()` when `$path` doesn't contain `://`.

Props pbiron, JPry, dontstealmyfish.
Merges [43466] to the 4.9 branch.
Fixes #44532.
Built from https://develop.svn.wordpress.org/branches/4.9@43484


git-svn-id: http://core.svn.wordpress.org/branches/4.9@43311 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2018-07-17 15:20:26 +00:00
parent 227534fae8
commit 1fadf698a1
2 changed files with 6 additions and 1 deletions

View File

@ -5227,6 +5227,11 @@ function _device_can_upload() {
* @return bool True if the path is a stream URL.
*/
function wp_is_stream( $path ) {
if ( false === strpos( $path, '://' ) ) {
// $path isn't a stream
return false;
}
$wrappers = stream_get_wrappers();
$wrappers = array_map( 'preg_quote', $wrappers );
$wrappers_re = '(' . join( '|', $wrappers ) . ')';

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9.8-alpha-43483';
$wp_version = '4.9.8-alpha-43484';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.